1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { AnimationEvent } from '@angular/animations';
|
---|
9 | import { AriaLivePoliteness } from '@angular/cdk/a11y';
|
---|
10 | import { Platform } from '@angular/cdk/platform';
|
---|
11 | import { BasePortalOutlet, CdkPortalOutlet, ComponentPortal, TemplatePortal, DomPortal } from '@angular/cdk/portal';
|
---|
12 | import { ChangeDetectorRef, ComponentRef, ElementRef, EmbeddedViewRef, NgZone, OnDestroy } from '@angular/core';
|
---|
13 | import { Observable, Subject } from 'rxjs';
|
---|
14 | import { MatSnackBarConfig } from './snack-bar-config';
|
---|
15 | /**
|
---|
16 | * Internal interface for a snack bar container.
|
---|
17 | * @docs-private
|
---|
18 | */
|
---|
19 | export interface _SnackBarContainer {
|
---|
20 | snackBarConfig: MatSnackBarConfig;
|
---|
21 | readonly _onAnnounce: Subject<any>;
|
---|
22 | readonly _onExit: Subject<any>;
|
---|
23 | readonly _onEnter: Subject<any>;
|
---|
24 | enter: () => void;
|
---|
25 | exit: () => Observable<void>;
|
---|
26 | attachTemplatePortal: <C>(portal: TemplatePortal<C>) => EmbeddedViewRef<C>;
|
---|
27 | attachComponentPortal: <T>(portal: ComponentPortal<T>) => ComponentRef<T>;
|
---|
28 | }
|
---|
29 | /**
|
---|
30 | * Internal component that wraps user-provided snack bar content.
|
---|
31 | * @docs-private
|
---|
32 | */
|
---|
33 | export declare class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy, _SnackBarContainer {
|
---|
34 | private _ngZone;
|
---|
35 | private _elementRef;
|
---|
36 | private _changeDetectorRef;
|
---|
37 | private _platform;
|
---|
38 | /** The snack bar configuration. */
|
---|
39 | snackBarConfig: MatSnackBarConfig;
|
---|
40 | /** The number of milliseconds to wait before announcing the snack bar's content. */
|
---|
41 | private readonly _announceDelay;
|
---|
42 | /** The timeout for announcing the snack bar's content. */
|
---|
43 | private _announceTimeoutId;
|
---|
44 | /** Whether the component has been destroyed. */
|
---|
45 | private _destroyed;
|
---|
46 | /** The portal outlet inside of this container into which the snack bar content will be loaded. */
|
---|
47 | _portalOutlet: CdkPortalOutlet;
|
---|
48 | /** Subject for notifying that the snack bar has announced to screen readers. */
|
---|
49 | readonly _onAnnounce: Subject<void>;
|
---|
50 | /** Subject for notifying that the snack bar has exited from view. */
|
---|
51 | readonly _onExit: Subject<void>;
|
---|
52 | /** Subject for notifying that the snack bar has finished entering the view. */
|
---|
53 | readonly _onEnter: Subject<void>;
|
---|
54 | /** The state of the snack bar animations. */
|
---|
55 | _animationState: string;
|
---|
56 | /** aria-live value for the live region. */
|
---|
57 | _live: AriaLivePoliteness;
|
---|
58 | /**
|
---|
59 | * Role of the live region. This is only for Firefox as there is a known issue where Firefox +
|
---|
60 | * JAWS does not read out aria-live message.
|
---|
61 | */
|
---|
62 | _role?: 'status' | 'alert';
|
---|
63 | constructor(_ngZone: NgZone, _elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, _platform: Platform,
|
---|
64 | /** The snack bar configuration. */
|
---|
65 | snackBarConfig: MatSnackBarConfig);
|
---|
66 | /** Attach a component portal as content to this snack bar container. */
|
---|
67 | attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>;
|
---|
68 | /** Attach a template portal as content to this snack bar container. */
|
---|
69 | attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
|
---|
70 | /**
|
---|
71 | * Attaches a DOM portal to the snack bar container.
|
---|
72 | * @deprecated To be turned into a method.
|
---|
73 | * @breaking-change 10.0.0
|
---|
74 | */
|
---|
75 | attachDomPortal: (portal: DomPortal) => void;
|
---|
76 | /** Handle end of animations, updating the state of the snackbar. */
|
---|
77 | onAnimationEnd(event: AnimationEvent): void;
|
---|
78 | /** Begin animation of snack bar entrance into view. */
|
---|
79 | enter(): void;
|
---|
80 | /** Begin animation of the snack bar exiting from view. */
|
---|
81 | exit(): Observable<void>;
|
---|
82 | /** Makes sure the exit callbacks have been invoked when the element is destroyed. */
|
---|
83 | ngOnDestroy(): void;
|
---|
84 | /**
|
---|
85 | * Waits for the zone to settle before removing the element. Helps prevent
|
---|
86 | * errors where we end up removing an element which is in the middle of an animation.
|
---|
87 | */
|
---|
88 | private _completeExit;
|
---|
89 | /** Applies the various positioning and user-configured CSS classes to the snack bar. */
|
---|
90 | private _applySnackBarClasses;
|
---|
91 | /** Asserts that no content is already attached to the container. */
|
---|
92 | private _assertNotAttached;
|
---|
93 | /**
|
---|
94 | * Starts a timeout to move the snack bar content to the live region so screen readers will
|
---|
95 | * announce it.
|
---|
96 | */
|
---|
97 | private _screenReaderAnnounce;
|
---|
98 | }
|
---|