/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Platform } from '@angular/cdk/platform'; import { BasePortalOutlet, CdkPortalOutlet, } from '@angular/cdk/portal'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, ViewChild, ViewEncapsulation, } from '@angular/core'; import { Subject } from 'rxjs'; import { take } from 'rxjs/operators'; import { matSnackBarAnimations } from './snack-bar-animations'; import { MatSnackBarConfig } from './snack-bar-config'; /** * Internal component that wraps user-provided snack bar content. * @docs-private */ export class MatSnackBarContainer extends BasePortalOutlet { constructor(_ngZone, _elementRef, _changeDetectorRef, _platform, /** The snack bar configuration. */ snackBarConfig) { super(); this._ngZone = _ngZone; this._elementRef = _elementRef; this._changeDetectorRef = _changeDetectorRef; this._platform = _platform; this.snackBarConfig = snackBarConfig; /** The number of milliseconds to wait before announcing the snack bar's content. */ this._announceDelay = 150; /** Whether the component has been destroyed. */ this._destroyed = false; /** Subject for notifying that the snack bar has announced to screen readers. */ this._onAnnounce = new Subject(); /** Subject for notifying that the snack bar has exited from view. */ this._onExit = new Subject(); /** Subject for notifying that the snack bar has finished entering the view. */ this._onEnter = new Subject(); /** The state of the snack bar animations. */ this._animationState = 'void'; /** * Attaches a DOM portal to the snack bar container. * @deprecated To be turned into a method. * @breaking-change 10.0.0 */ this.attachDomPortal = (portal) => { this._assertNotAttached(); this._applySnackBarClasses(); return this._portalOutlet.attachDomPortal(portal); }; // Use aria-live rather than a live role like 'alert' or 'status' // because NVDA and JAWS have show inconsistent behavior with live roles. if (snackBarConfig.politeness === 'assertive' && !snackBarConfig.announcementMessage) { this._live = 'assertive'; } else if (snackBarConfig.politeness === 'off') { this._live = 'off'; } else { this._live = 'polite'; } // Only set role for Firefox. Set role based on aria-live because setting role="alert" implies // aria-live="assertive" which may cause issues if aria-live is set to "polite" above. if (this._platform.FIREFOX) { if (this._live === 'polite') { this._role = 'status'; } if (this._live === 'assertive') { this._role = 'alert'; } } } /** Attach a component portal as content to this snack bar container. */ attachComponentPortal(portal) { this._assertNotAttached(); this._applySnackBarClasses(); return this._portalOutlet.attachComponentPortal(portal); } /** Attach a template portal as content to this snack bar container. */ attachTemplatePortal(portal) { this._assertNotAttached(); this._applySnackBarClasses(); return this._portalOutlet.attachTemplatePortal(portal); } /** Handle end of animations, updating the state of the snackbar. */ onAnimationEnd(event) { const { fromState, toState } = event; if ((toState === 'void' && fromState !== 'void') || toState === 'hidden') { this._completeExit(); } if (toState === 'visible') { // Note: we shouldn't use `this` inside the zone callback, // because it can cause a memory leak. const onEnter = this._onEnter; this._ngZone.run(() => { onEnter.next(); onEnter.complete(); }); } } /** Begin animation of snack bar entrance into view. */ enter() { if (!this._destroyed) { this._animationState = 'visible'; this._changeDetectorRef.detectChanges(); this._screenReaderAnnounce(); } } /** Begin animation of the snack bar exiting from view. */ exit() { // Note: this one transitions to `hidden`, rather than `void`, in order to handle the case // where multiple snack bars are opened in quick succession (e.g. two consecutive calls to // `MatSnackBar.open`). this._animationState = 'hidden'; // Mark this element with an 'exit' attribute to indicate that the snackbar has // been dismissed and will soon be removed from the DOM. This is used by the snackbar // test harness. this._elementRef.nativeElement.setAttribute('mat-exit', ''); // If the snack bar hasn't been announced by the time it exits it wouldn't have been open // long enough to visually read it either, so clear the timeout for announcing. clearTimeout(this._announceTimeoutId); return this._onExit; } /** Makes sure the exit callbacks have been invoked when the element is destroyed. */ ngOnDestroy() { this._destroyed = true; this._completeExit(); } /** * Waits for the zone to settle before removing the element. Helps prevent * errors where we end up removing an element which is in the middle of an animation. */ _completeExit() { this._ngZone.onMicrotaskEmpty.pipe(take(1)).subscribe(() => { this._onExit.next(); this._onExit.complete(); }); } /** Applies the various positioning and user-configured CSS classes to the snack bar. */ _applySnackBarClasses() { const element = this._elementRef.nativeElement; const panelClasses = this.snackBarConfig.panelClass; if (panelClasses) { if (Array.isArray(panelClasses)) { // Note that we can't use a spread here, because IE doesn't support multiple arguments. panelClasses.forEach(cssClass => element.classList.add(cssClass)); } else { element.classList.add(panelClasses); } } if (this.snackBarConfig.horizontalPosition === 'center') { element.classList.add('mat-snack-bar-center'); } if (this.snackBarConfig.verticalPosition === 'top') { element.classList.add('mat-snack-bar-top'); } } /** Asserts that no content is already attached to the container. */ _assertNotAttached() { if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error('Attempting to attach snack bar content after content is already attached'); } } /** * Starts a timeout to move the snack bar content to the live region so screen readers will * announce it. */ _screenReaderAnnounce() { if (!this._announceTimeoutId) { this._ngZone.runOutsideAngular(() => { this._announceTimeoutId = setTimeout(() => { const inertElement = this._elementRef.nativeElement.querySelector('[aria-hidden]'); const liveElement = this._elementRef.nativeElement.querySelector('[aria-live]'); if (inertElement && liveElement) { // If an element in the snack bar content is focused before being moved // track it and restore focus after moving to the live region. let focusedElement = null; if (this._platform.isBrowser && document.activeElement instanceof HTMLElement && inertElement.contains(document.activeElement)) { focusedElement = document.activeElement; } inertElement.removeAttribute('aria-hidden'); liveElement.appendChild(inertElement); focusedElement === null || focusedElement === void 0 ? void 0 : focusedElement.focus(); this._onAnnounce.next(); this._onAnnounce.complete(); } }, this._announceDelay); }); } } } MatSnackBarContainer.decorators = [ { type: Component, args: [{ selector: 'snack-bar-container', template: "\n
\n \n
\n\n\n
\n", // In Ivy embedded views will be change detected from their declaration place, rather than // where they were stamped out. This means that we can't have the snack bar container be OnPush, // because it might cause snack bars that were opened from a template not to be out of date. // tslint:disable-next-line:validate-decorators changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, animations: [matSnackBarAnimations.snackBarState], host: { 'class': 'mat-snack-bar-container', '[@state]': '_animationState', '(@state.done)': 'onAnimationEnd($event)' }, styles: [".mat-snack-bar-container{border-radius:4px;box-sizing:border-box;display:block;margin:24px;max-width:33vw;min-width:344px;padding:14px 16px;min-height:48px;transform-origin:center}.cdk-high-contrast-active .mat-snack-bar-container{border:solid 1px}.mat-snack-bar-handset{width:100%}.mat-snack-bar-handset .mat-snack-bar-container{margin:8px;max-width:100%;min-width:0;width:100%}\n"] },] } ]; MatSnackBarContainer.ctorParameters = () => [ { type: NgZone }, { type: ElementRef }, { type: ChangeDetectorRef }, { type: Platform }, { type: MatSnackBarConfig } ]; MatSnackBarContainer.propDecorators = { _portalOutlet: [{ type: ViewChild, args: [CdkPortalOutlet, { static: true },] }] }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic25hY2stYmFyLWNvbnRhaW5lci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9zbmFjay1iYXIvc25hY2stYmFyLWNvbnRhaW5lci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFJSCxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUFDL0MsT0FBTyxFQUNMLGdCQUFnQixFQUNoQixlQUFlLEdBSWhCLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxFQUNMLHVCQUF1QixFQUN2QixpQkFBaUIsRUFDakIsU0FBUyxFQUVULFVBQVUsRUFFVixNQUFNLEVBRU4sU0FBUyxFQUNULGlCQUFpQixHQUNsQixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQWEsT0FBTyxFQUFDLE1BQU0sTUFBTSxDQUFDO0FBQ3pDLE9BQU8sRUFBQyxJQUFJLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUNwQyxPQUFPLEVBQUMscUJBQXFCLEVBQUMsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEVBQUMsaUJBQWlCLEVBQUMsTUFBTSxvQkFBb0IsQ0FBQztBQWlCckQ7OztHQUdHO0FBa0JILE1BQU0sT0FBTyxvQkFBcUIsU0FBUSxnQkFBZ0I7SUFtQ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