UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

79 lines 3.86 kB
import { InjectionToken, Injector } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { BsModalService } from 'ngx-bootstrap/modal'; import { ModalOptions } from 'ngx-bootstrap/modal/modal-options.class'; import { ComponentType } from '@angular/cdk/overlay'; import { Observable } from 'rxjs'; import { ExtensionFactory, ExtensionPointWithoutStateForPlugins, GenericHookOptions, GenericHookType } from '../common'; import { QueryParamConfig } from './query-param-handler.service'; import { PluginsResolveService } from '../plugins'; import * as i0 from "@angular/core"; export interface QueryParamModalConfig { /** * The name of the query parameter to observe. */ queryParam: string; /** * The component to display in the modal. */ component: ComponentType<any>; /** * Optional configuration settings for the modal. */ modalConfig?: ModalOptions; /** * The injector to use. If not set, the default root injector will be used. */ injector?: Injector; } export declare const HOOK_QUERY_PARAM_MODAL: InjectionToken<QueryParamModalConfig[]>; export declare function hookQueryParamModal(config: GenericHookType<QueryParamModalConfig>, options?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ExistingProvider | import("@angular/core").ClassProvider; /** * Service to manage the display of modals based on URL query parameter. * * This service listens for specific query parameters in the URL and opens corresponding modals when detected. * It automatically cleans up the query parameters from the URL when the modal is closed or query parameter value passed as 'false'. */ export declare class QueryParamModalStateService extends ExtensionPointWithoutStateForPlugins<QueryParamModalConfig> { constructor(rootInjector: Injector, pluginService: PluginsResolveService); protected setupItemsObservable(): Observable<QueryParamModalConfig[]>; static ɵfac: i0.ɵɵFactoryDeclaration<QueryParamModalStateService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<QueryParamModalStateService>; } export declare class QueryParamModalFactory implements ExtensionFactory<QueryParamConfig> { private readonly queryParamModalStateService; private readonly bsModalService; private readonly router; private readonly activatedRoute; private modalCloseSubscription; constructor(queryParamModalStateService: QueryParamModalStateService, bsModalService: BsModalService, router: Router, activatedRoute: ActivatedRoute); get(): Observable<QueryParamConfig[]>; /** * Handles the display of a modal based on a specific query parameter. * * @param config - Configuration object specifying the query parameter, component, and optional modal settings. * @returns An observable that listens for changes in the query parameter. */ handleQueryParamModal(config: QueryParamModalConfig): void; /** * Removes the specified query parameter from the URL. * * @param paramKey - The key of the query parameter to remove. */ private removeQueryParam; /** * Displays a modal with the specified component and configuration. * * @param component - The component to display in the modal. * @param modalConfig - Optional settings for the modal appearance and behavior. */ private showModal; /** * Cleans up subscriptions related to modal events. * Ensures no memory leaks by unsubscribing from modal close events. */ private cleanup; static ɵfac: i0.ɵɵFactoryDeclaration<QueryParamModalFactory, [null, null, null, { optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<QueryParamModalFactory>; } //# sourceMappingURL=query-param-modal-handler.service.d.ts.map