UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

77 lines 3.08 kB
import { ParamMap } from '@angular/router'; import { ModalOptions } from 'ngx-bootstrap/modal/modal-options.class'; import { ComponentType } from '@angular/cdk/overlay'; import { Observable } from 'rxjs'; import * as i0 from "@angular/core"; /** * Interface representing the configuration for handling query parameter-based modals. */ 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; } /** * 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 QueryParamModalHandlerService { private readonly activatedRoute; private readonly bsModalService; private readonly router; /** * Subscription to track modal close events. */ private modalCloseSubscription; /** * 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): Observable<ParamMap>; /** * 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; /** * Parses a string representation of a query parameter into a boolean or null. * * Converts the provided `queryParam` string into a boolean value or null based on its content: * - Returns `true` if `queryParam` is 'true'. * - Returns `false` if `queryParam` is 'false'. * - Returns `null` if `queryParam` is neither 'true' nor 'false'. * * @param queryParam - The string representation of the query parameter. * @returns A boolean value corresponding to the parsed state, or null if the input is not 'true' or 'false'. */ private parseQueryParam; static ɵfac: i0.ɵɵFactoryDeclaration<QueryParamModalHandlerService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<QueryParamModalHandlerService>; } //# sourceMappingURL=query-param-modal-handler.service.d.ts.map