UNPKG

@studiohyperdrive/ngx-inform

Version:

A lightweight ARIA compliant customizable approach for common and complex inform flows in Angular.

67 lines (66 loc) 2.36 kB
import { Dialog } from '@angular/cdk/dialog'; import { Observable } from 'rxjs'; import { NgxModalActionType, NgxModalConfiguration, NgxModalOptions } from '../../types'; import * as i0 from "@angular/core"; /** * A wrapper service to Angular CDK Dialog that provides a WCAG/ARIA compliant implementation of modals * * @export * @class NgxModalService */ export declare class NgxModalService { private readonly configuration; private readonly dialogService; /** * A subject that keeps track of whether a modal is currently active */ private hasModalSubject; /** * An observable that keeps track of whether a modal is currently active. */ readonly hasActiveModal$: Observable<boolean>; constructor(configuration: NgxModalConfiguration, dialogService: Dialog); /** * Opens a modal based on the provided options * * @param {NgxModalOptions<ActionType>} options - The modal options */ open<ActionType extends NgxModalActionType = string, DataType = any>(options: NgxModalOptions<ActionType, DataType>): Observable<ActionType>; /** * Closes the currently active modal * * * @param onClose - An optional onClose function */ close(onClose?: () => void): void; /** * Checks if all the necessary preconditions are met * * @param options - The options of the modal * @param component - The component we wish to render */ private runARIAChecks; /** * Creates the modal component * * @param options - The options of the modal * @param component - The component we wish to render */ private createModalComponent; /** * Checks if the description is provided when the role requires it * * @param options - The options of the modal */ private hasRequiredDescription; /** * Returns a value based on whether one of the overwrites is defined * * @private * @param configurationValue - The overwrite on configuration level * @param optionsValue - The overwrite on options level * @param defaultValue - The default value if no overwrite was defined */ private getValue; static ɵfac: i0.ɵɵFactoryDeclaration<NgxModalService, [{ optional: true; }, null]>; static ɵprov: i0.ɵɵInjectableDeclaration<NgxModalService>; }