UNPKG

@versatiledatakit/shared

Version:

Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.

114 lines (113 loc) 6.64 kB
import { ActivatedRoute, ActivatedRouteSnapshot, NavigationExtras, Router } from '@angular/router'; import { ArrayElement } from '../../../utils'; import { TaurusNavigateAction } from '../../../common'; import { SystemEventNavigatePayload } from '../../system-events'; import { RouterService, RouteState } from '../../router'; import * as i0 from "@angular/core"; /** * ** Service should be provided from the Root injector in Application. */ export declare class NavigationService { private readonly router; private readonly routerService; private readonly _routeStateFactory; /** * ** Constructor. */ constructor(router: Router, routerService: RouterService); /** * ** Intercept SE_NAVIGATE Event and handle (react) on it. */ _navigationSystemEventHandler_(payload: SystemEventNavigatePayload): Promise<boolean>; /** * ** Navigate to url with provided extras. */ navigate(url: string | string[], extras?: NavigationExtras): Promise<boolean>; /** * ** Navigate to using Route config, RouteState and leveraging provided optional replaceValueResolver. * * @param replaceValues is Object with mapping between Replacer.replaceValue key pointer to dynamic value specific for the Page. * - What does it mean? * Replacer has searchValue and replaceValue. When searchValue match, it replace with replaceValue, but * replaceValue could be something like '$.team', '$.job', '{0}', '{1}' etc... dynamic params, so those params * could be key in this Map to construct correct url depending of the logic in RouteConfig. * <p> * Important!!! * - If replaceValues is not provided or some key doesn't exist there, replaceValue would be use as it is in the RouteConfig. * </p> * <p></p> * @param activatedRoute is optional and could be provided if you want those state to be used to extract RouteConfig and NavigationAction. */ navigateTo(replaceValues?: { [key: string]: ArrayElement<TaurusNavigateAction['replacers']>['replaceValue']; }, activatedRoute?: ActivatedRoute | ActivatedRouteSnapshot): Promise<boolean>; /** * ** Navigate back using Route config, RouteState and leveraging provided optional replaceValueResolver. * * @param replaceValues is Object with mapping between Replacer.replaceValue key pointer to dynamic value specific for the Page. * - What does it mean? * Replacer has searchValue and replaceValue. When searchValue match, it replace with replaceValue, but * replaceValue could be something like '$.team', '$.job', '{0}', '{1}' etc... dynamic params, so those params * could be key in this Map to construct correct url depending of the logic in RouteConfig. * <p> * Important!!! * - If replaceValues is not provided or some key doesn't exist there, replaceValue would be use as it is in the RouteConfig. * </p> * <p></p> * @param activatedRoute is optional and could be provided if you want those state to be used to extract RouteConfig and NavigationAction. */ navigateBack(replaceValues?: { [key: string]: ArrayElement<TaurusNavigateAction['replacers']>['replaceValue']; }, activatedRoute?: ActivatedRoute | ActivatedRouteSnapshot): Promise<boolean>; /** * ** Redirect using Route config, RouteState and leveraging provided optional replaceValueResolver. * * @param replaceValues is Object with mapping between Replacer.replaceValue key pointer to dynamic value specific for the Page. * - What does it mean? * Replacer has searchValue and replaceValue. When searchValue match, it replace with replaceValue, but * replaceValue could be something like '$.team', '$.job', '{0}', '{1}' etc... dynamic params, so those params * could be key in this Map to construct correct url depending of the logic in RouteConfig. * <p> * Important!!! * - If replaceValues is not provided or some key doesn't exist there, replaceValue would be use as it is in the RouteConfig. * </p> * <p></p> * @param activatedRoute is optional and could be provided if you want those state to be used to extract RouteConfig and NavigationAction. */ redirect(replaceValues?: { [key: string]: ArrayElement<TaurusNavigateAction['replacers']>['replaceValue']; }, activatedRoute?: ActivatedRoute | ActivatedRouteSnapshot): Promise<boolean>; /** * ** Resolve NavigationAction using Route config, RouteState and leveraging provided optional replaceValueResolver. * @param navigateActionType is the type of the NavigationAction we want to resolve from Route config. * @param replaceValues is Object with mapping between Replacer.replaceValue key pointer to dynamic value specific for the Page. * - What does it mean? * Replacer has searchValue and replaceValue. When searchValue match, it replace with replaceValue, but * replaceValue could be something like '$.team', '$.job', '{0}', '{1}' etc... dynamic params, so those params * could be key in this Map to construct correct url depending of the logic in RouteConfig. * <p> * Important!!! * - If replaceValues is not provided or some key doesn't exist there, replaceValue would be use as it is in the RouteConfig. * </p> * <p></p> * @param activatedRoute is optional and could be provided if you want those state to be used to extract RouteConfig and NavigationAction. */ resolveNavigateActionUrl(navigateActionType: 'navigateTo' | 'navigateBack' | 'redirect', replaceValues?: { [key: string]: ArrayElement<TaurusNavigateAction['replacers']>['replaceValue']; }, activatedRoute?: ActivatedRoute | ActivatedRouteSnapshot | RouteState): Promise<[string, NavigationExtras]>; /** * ** Initialize the Service without any operation, just to create singleton Service instance. * * - It should be done in the root of the project only once. * - Possible place is AppComponent or some root initializer guard. */ initialize(): void; private _navigateWithAction; private _extractRouteState; private _constructNavigateParameters; private _resolveNavigateUrl; private _appendNavigateExtras; private _resolveNavigateValues; static ɵfac: i0.ɵɵFactoryDeclaration<NavigationService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NavigationService>; }