UNPKG

@xui/components

Version:

xUI Components for Angular

88 lines (87 loc) 4.33 kB
import { ChangeDetectorRef, ComponentRef, ElementRef, EmbeddedViewRef, NgZone, OnDestroy } from '@angular/core'; import { BasePortalOutlet, CdkPortalOutlet, ComponentPortal, DomPortal, TemplatePortal } from '@angular/cdk/portal'; import { SnackBarConfig } from '../config/config'; import { AriaLivePoliteness } from '@angular/cdk/a11y'; import { Platform } from '@angular/cdk/platform'; import { Observable, Subject } from 'rxjs'; import { AnimationEvent } from '@angular/animations'; import * as i0 from "@angular/core"; export declare class SnackBarContainer extends BasePortalOutlet implements OnDestroy { snackBarConfig: SnackBarConfig; private platform; private ngZone; private changeDetectorRef; private elementRef; private document; private trackedModals; /** aria-live value for the live region. */ live: AriaLivePoliteness; /** The number of milliseconds to wait before announcing the snack bar's content. */ private readonly _announceDelay; /** The timeout for announcing the snack bar's content. */ private _announceTimeoutId; /** Subject for notifying that the snack bar has announced to screen readers. */ readonly onAnnounce: Subject<void>; /** Subject for notifying that the snack bar has exited from view. */ readonly onExit: Subject<void>; /** Subject for notifying that the snack bar has finished entering the view. */ readonly onEnter: Subject<void>; /** The state of the snack bar animations. */ _animationState: string; /** Whether the component has been destroyed. */ private _destroyed; /** * Element that will have the `x-snack-bar__label` class applied if the attached component * or template does not have it. This ensures that the appropriate structure, typography, and * color is applied to the attached view. */ label: ElementRef; /** * Role of the live region. This is only for Firefox as there is a known issue where Firefox + * JAWS does not read out aria-live message. */ role?: 'status' | 'alert'; /** Unique ID of the aria-live element. */ readonly liveElementId: string; /** The portal outlet inside of this container into which the snack bar content will be loaded. */ portalOutlet: CdkPortalOutlet; constructor(snackBarConfig: SnackBarConfig, platform: Platform, ngZone: NgZone, changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef<HTMLElement>); attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>; attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>; attachDomPortal: (portal: DomPortal) => void; /** Handle end of animations, updating the state of the snackbar. */ onAnimationEnd(event: AnimationEvent): void; /** Begin animation of snack bar entrance into view. */ enter(): void; /** Begin animation of the snack bar exiting from view. */ exit(): Observable<void>; /** Makes sure the exit callbacks have been invoked when the element is destroyed. */ ngOnDestroy(): void; /** * Removes the element in a microtask. Helps prevent errors where we end up * removing an element which is in the middle of an animation. */ private completeExit; /** * Called after the portal contents have been attached. Can be * used to modify the DOM once it's guaranteed to be in place. */ private afterPortalAttached; /** * Some browsers won't expose the accessibility node of the live element if there is an * `aria-modal` and the live element is outside of it. This method works around the issue by * pointing the `aria-owns` of all modals to the live element. */ private exposeToModals; /** Clears the references to the live element from any modals it was added to. */ private clearFromModals; /** * Starts a timeout to move the snack bar content to the live region so screen readers will * announce it. */ private screenReaderAnnounce; /** Asserts that no content is already attached to the container. */ private assertNotAttached; static ɵfac: i0.ɵɵFactoryDeclaration<SnackBarContainer, never>; static ɵcmp: i0.ɵɵComponentDeclaration<SnackBarContainer, "xui-snack-bar-container", never, {}, {}, never, never, true, never>; }