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 { Platform } from '@angular/cdk/platform';
|
---|
9 | import { BasePortalOutlet, CdkPortalOutlet, } from '@angular/cdk/portal';
|
---|
10 | import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, ViewChild, ViewEncapsulation, } from '@angular/core';
|
---|
11 | import { Subject } from 'rxjs';
|
---|
12 | import { take } from 'rxjs/operators';
|
---|
13 | import { matSnackBarAnimations } from './snack-bar-animations';
|
---|
14 | import { MatSnackBarConfig } from './snack-bar-config';
|
---|
15 | /**
|
---|
16 | * Internal component that wraps user-provided snack bar content.
|
---|
17 | * @docs-private
|
---|
18 | */
|
---|
19 | export class MatSnackBarContainer extends BasePortalOutlet {
|
---|
20 | constructor(_ngZone, _elementRef, _changeDetectorRef, _platform,
|
---|
21 | /** The snack bar configuration. */
|
---|
22 | snackBarConfig) {
|
---|
23 | super();
|
---|
24 | this._ngZone = _ngZone;
|
---|
25 | this._elementRef = _elementRef;
|
---|
26 | this._changeDetectorRef = _changeDetectorRef;
|
---|
27 | this._platform = _platform;
|
---|
28 | this.snackBarConfig = snackBarConfig;
|
---|
29 | /** The number of milliseconds to wait before announcing the snack bar's content. */
|
---|
30 | this._announceDelay = 150;
|
---|
31 | /** Whether the component has been destroyed. */
|
---|
32 | this._destroyed = false;
|
---|
33 | /** Subject for notifying that the snack bar has announced to screen readers. */
|
---|
34 | this._onAnnounce = new Subject();
|
---|
35 | /** Subject for notifying that the snack bar has exited from view. */
|
---|
36 | this._onExit = new Subject();
|
---|
37 | /** Subject for notifying that the snack bar has finished entering the view. */
|
---|
38 | this._onEnter = new Subject();
|
---|
39 | /** The state of the snack bar animations. */
|
---|
40 | this._animationState = 'void';
|
---|
41 | /**
|
---|
42 | * Attaches a DOM portal to the snack bar container.
|
---|
43 | * @deprecated To be turned into a method.
|
---|
44 | * @breaking-change 10.0.0
|
---|
45 | */
|
---|
46 | this.attachDomPortal = (portal) => {
|
---|
47 | this._assertNotAttached();
|
---|
48 | this._applySnackBarClasses();
|
---|
49 | return this._portalOutlet.attachDomPortal(portal);
|
---|
50 | };
|
---|
51 | // Use aria-live rather than a live role like 'alert' or 'status'
|
---|
52 | // because NVDA and JAWS have show inconsistent behavior with live roles.
|
---|
53 | if (snackBarConfig.politeness === 'assertive' && !snackBarConfig.announcementMessage) {
|
---|
54 | this._live = 'assertive';
|
---|
55 | }
|
---|
56 | else if (snackBarConfig.politeness === 'off') {
|
---|
57 | this._live = 'off';
|
---|
58 | }
|
---|
59 | else {
|
---|
60 | this._live = 'polite';
|
---|
61 | }
|
---|
62 | // Only set role for Firefox. Set role based on aria-live because setting role="alert" implies
|
---|
63 | // aria-live="assertive" which may cause issues if aria-live is set to "polite" above.
|
---|
64 | if (this._platform.FIREFOX) {
|
---|
65 | if (this._live === 'polite') {
|
---|
66 | this._role = 'status';
|
---|
67 | }
|
---|
68 | if (this._live === 'assertive') {
|
---|
69 | this._role = 'alert';
|
---|
70 | }
|
---|
71 | }
|
---|
72 | }
|
---|
73 | /** Attach a component portal as content to this snack bar container. */
|
---|
74 | attachComponentPortal(portal) {
|
---|
75 | this._assertNotAttached();
|
---|
76 | this._applySnackBarClasses();
|
---|
77 | return this._portalOutlet.attachComponentPortal(portal);
|
---|
78 | }
|
---|
79 | /** Attach a template portal as content to this snack bar container. */
|
---|
80 | attachTemplatePortal(portal) {
|
---|
81 | this._assertNotAttached();
|
---|
82 | this._applySnackBarClasses();
|
---|
83 | return this._portalOutlet.attachTemplatePortal(portal);
|
---|
84 | }
|
---|
85 | /** Handle end of animations, updating the state of the snackbar. */
|
---|
86 | onAnimationEnd(event) {
|
---|
87 | const { fromState, toState } = event;
|
---|
88 | if ((toState === 'void' && fromState !== 'void') || toState === 'hidden') {
|
---|
89 | this._completeExit();
|
---|
90 | }
|
---|
91 | if (toState === 'visible') {
|
---|
92 | // Note: we shouldn't use `this` inside the zone callback,
|
---|
93 | // because it can cause a memory leak.
|
---|
94 | const onEnter = this._onEnter;
|
---|
95 | this._ngZone.run(() => {
|
---|
96 | onEnter.next();
|
---|
97 | onEnter.complete();
|
---|
98 | });
|
---|
99 | }
|
---|
100 | }
|
---|
101 | /** Begin animation of snack bar entrance into view. */
|
---|
102 | enter() {
|
---|
103 | if (!this._destroyed) {
|
---|
104 | this._animationState = 'visible';
|
---|
105 | this._changeDetectorRef.detectChanges();
|
---|
106 | this._screenReaderAnnounce();
|
---|
107 | }
|
---|
108 | }
|
---|
109 | /** Begin animation of the snack bar exiting from view. */
|
---|
110 | exit() {
|
---|
111 | // Note: this one transitions to `hidden`, rather than `void`, in order to handle the case
|
---|
112 | // where multiple snack bars are opened in quick succession (e.g. two consecutive calls to
|
---|
113 | // `MatSnackBar.open`).
|
---|
114 | this._animationState = 'hidden';
|
---|
115 | // Mark this element with an 'exit' attribute to indicate that the snackbar has
|
---|
116 | // been dismissed and will soon be removed from the DOM. This is used by the snackbar
|
---|
117 | // test harness.
|
---|
118 | this._elementRef.nativeElement.setAttribute('mat-exit', '');
|
---|
119 | // If the snack bar hasn't been announced by the time it exits it wouldn't have been open
|
---|
120 | // long enough to visually read it either, so clear the timeout for announcing.
|
---|
121 | clearTimeout(this._announceTimeoutId);
|
---|
122 | return this._onExit;
|
---|
123 | }
|
---|
124 | /** Makes sure the exit callbacks have been invoked when the element is destroyed. */
|
---|
125 | ngOnDestroy() {
|
---|
126 | this._destroyed = true;
|
---|
127 | this._completeExit();
|
---|
128 | }
|
---|
129 | /**
|
---|
130 | * Waits for the zone to settle before removing the element. Helps prevent
|
---|
131 | * errors where we end up removing an element which is in the middle of an animation.
|
---|
132 | */
|
---|
133 | _completeExit() {
|
---|
134 | this._ngZone.onMicrotaskEmpty.pipe(take(1)).subscribe(() => {
|
---|
135 | this._onExit.next();
|
---|
136 | this._onExit.complete();
|
---|
137 | });
|
---|
138 | }
|
---|
139 | /** Applies the various positioning and user-configured CSS classes to the snack bar. */
|
---|
140 | _applySnackBarClasses() {
|
---|
141 | const element = this._elementRef.nativeElement;
|
---|
142 | const panelClasses = this.snackBarConfig.panelClass;
|
---|
143 | if (panelClasses) {
|
---|
144 | if (Array.isArray(panelClasses)) {
|
---|
145 | // Note that we can't use a spread here, because IE doesn't support multiple arguments.
|
---|
146 | panelClasses.forEach(cssClass => element.classList.add(cssClass));
|
---|
147 | }
|
---|
148 | else {
|
---|
149 | element.classList.add(panelClasses);
|
---|
150 | }
|
---|
151 | }
|
---|
152 | if (this.snackBarConfig.horizontalPosition === 'center') {
|
---|
153 | element.classList.add('mat-snack-bar-center');
|
---|
154 | }
|
---|
155 | if (this.snackBarConfig.verticalPosition === 'top') {
|
---|
156 | element.classList.add('mat-snack-bar-top');
|
---|
157 | }
|
---|
158 | }
|
---|
159 | /** Asserts that no content is already attached to the container. */
|
---|
160 | _assertNotAttached() {
|
---|
161 | if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
162 | throw Error('Attempting to attach snack bar content after content is already attached');
|
---|
163 | }
|
---|
164 | }
|
---|
165 | /**
|
---|
166 | * Starts a timeout to move the snack bar content to the live region so screen readers will
|
---|
167 | * announce it.
|
---|
168 | */
|
---|
169 | _screenReaderAnnounce() {
|
---|
170 | if (!this._announceTimeoutId) {
|
---|
171 | this._ngZone.runOutsideAngular(() => {
|
---|
172 | this._announceTimeoutId = setTimeout(() => {
|
---|
173 | const inertElement = this._elementRef.nativeElement.querySelector('[aria-hidden]');
|
---|
174 | const liveElement = this._elementRef.nativeElement.querySelector('[aria-live]');
|
---|
175 | if (inertElement && liveElement) {
|
---|
176 | // If an element in the snack bar content is focused before being moved
|
---|
177 | // track it and restore focus after moving to the live region.
|
---|
178 | let focusedElement = null;
|
---|
179 | if (this._platform.isBrowser &&
|
---|
180 | document.activeElement instanceof HTMLElement &&
|
---|
181 | inertElement.contains(document.activeElement)) {
|
---|
182 | focusedElement = document.activeElement;
|
---|
183 | }
|
---|
184 | inertElement.removeAttribute('aria-hidden');
|
---|
185 | liveElement.appendChild(inertElement);
|
---|
186 | focusedElement === null || focusedElement === void 0 ? void 0 : focusedElement.focus();
|
---|
187 | this._onAnnounce.next();
|
---|
188 | this._onAnnounce.complete();
|
---|
189 | }
|
---|
190 | }, this._announceDelay);
|
---|
191 | });
|
---|
192 | }
|
---|
193 | }
|
---|
194 | }
|
---|
195 | MatSnackBarContainer.decorators = [
|
---|
196 | { type: Component, args: [{
|
---|
197 | selector: 'snack-bar-container',
|
---|
198 | template: "<!-- Initially holds the snack bar content, will be empty after announcing to screen readers. -->\n<div aria-hidden=\"true\">\n <ng-template cdkPortalOutlet></ng-template>\n</div>\n\n<!-- Will receive the snack bar content from the non-live div, move will happen a short delay after opening -->\n<div [attr.aria-live]=\"_live\" [attr.role]=\"_role\"></div>\n",
|
---|
199 | // In Ivy embedded views will be change detected from their declaration place, rather than
|
---|
200 | // where they were stamped out. This means that we can't have the snack bar container be OnPush,
|
---|
201 | // because it might cause snack bars that were opened from a template not to be out of date.
|
---|
202 | // tslint:disable-next-line:validate-decorators
|
---|
203 | changeDetection: ChangeDetectionStrategy.Default,
|
---|
204 | encapsulation: ViewEncapsulation.None,
|
---|
205 | animations: [matSnackBarAnimations.snackBarState],
|
---|
206 | host: {
|
---|
207 | 'class': 'mat-snack-bar-container',
|
---|
208 | '[@state]': '_animationState',
|
---|
209 | '(@state.done)': 'onAnimationEnd($event)'
|
---|
210 | },
|
---|
211 | 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"]
|
---|
212 | },] }
|
---|
213 | ];
|
---|
214 | MatSnackBarContainer.ctorParameters = () => [
|
---|
215 | { type: NgZone },
|
---|
216 | { type: ElementRef },
|
---|
217 | { type: ChangeDetectorRef },
|
---|
218 | { type: Platform },
|
---|
219 | { type: MatSnackBarConfig }
|
---|
220 | ];
|
---|
221 | MatSnackBarContainer.propDecorators = {
|
---|
222 | _portalOutlet: [{ type: ViewChild, args: [CdkPortalOutlet, { static: true },] }]
|
---|
223 | };
|
---|
224 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic25hY2stYmFyLWNvbnRhaW5lci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9zbmFjay1iYXIvc25hY2stYmFyLWNvbnRhaW5lci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFJSCxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUFDL0MsT0FBTyxFQUNMLGdCQUFnQixFQUNoQixlQUFlLEdBSWhCLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxFQUNMLHVCQUF1QixFQUN2QixpQkFBaUIsRUFDakIsU0FBUyxFQUVULFVBQVUsRUFFVixNQUFNLEVBRU4sU0FBUyxFQUNULGlCQUFpQixHQUNsQixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQWEsT0FBTyxFQUFDLE1BQU0sTUFBTSxDQUFDO0FBQ3pDLE9BQU8sRUFBQyxJQUFJLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUNwQyxPQUFPLEVBQUMscUJBQXFCLEVBQUMsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEVBQUMsaUJBQWlCLEVBQUMsTUFBTSxvQkFBb0IsQ0FBQztBQWlCckQ7OztHQUdHO0FBa0JILE1BQU0sT0FBTyxvQkFBcUIsU0FB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