snack-bar.mjs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. import * as i0 from '@angular/core';
  2. import { InjectionToken, Directive, Component, ViewEncapsulation, ChangeDetectionStrategy, Inject, inject, ViewChild, NgModule, Injector, TemplateRef, Injectable, Optional, SkipSelf } from '@angular/core';
  3. import { Subject } from 'rxjs';
  4. import * as i2 from '@angular/common';
  5. import { DOCUMENT, CommonModule } from '@angular/common';
  6. import * as i3 from '@angular/material/button';
  7. import { MatButtonModule } from '@angular/material/button';
  8. import { trigger, state, style, transition, animate } from '@angular/animations';
  9. import * as i3$1 from '@angular/cdk/portal';
  10. import { BasePortalOutlet, CdkPortalOutlet, PortalModule, ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
  11. import * as i1 from '@angular/cdk/platform';
  12. import { take, takeUntil } from 'rxjs/operators';
  13. import * as i2$1 from '@angular/cdk/a11y';
  14. import * as i3$2 from '@angular/cdk/layout';
  15. import { Breakpoints } from '@angular/cdk/layout';
  16. import * as i1$1 from '@angular/cdk/overlay';
  17. import { OverlayModule, OverlayConfig } from '@angular/cdk/overlay';
  18. import { MatCommonModule } from '@angular/material/core';
  19. /** Maximum amount of milliseconds that can be passed into setTimeout. */
  20. const MAX_TIMEOUT = Math.pow(2, 31) - 1;
  21. /**
  22. * Reference to a snack bar dispatched from the snack bar service.
  23. */
  24. class MatSnackBarRef {
  25. constructor(containerInstance, _overlayRef) {
  26. this._overlayRef = _overlayRef;
  27. /** Subject for notifying the user that the snack bar has been dismissed. */
  28. this._afterDismissed = new Subject();
  29. /** Subject for notifying the user that the snack bar has opened and appeared. */
  30. this._afterOpened = new Subject();
  31. /** Subject for notifying the user that the snack bar action was called. */
  32. this._onAction = new Subject();
  33. /** Whether the snack bar was dismissed using the action button. */
  34. this._dismissedByAction = false;
  35. this.containerInstance = containerInstance;
  36. containerInstance._onExit.subscribe(() => this._finishDismiss());
  37. }
  38. /** Dismisses the snack bar. */
  39. dismiss() {
  40. if (!this._afterDismissed.closed) {
  41. this.containerInstance.exit();
  42. }
  43. clearTimeout(this._durationTimeoutId);
  44. }
  45. /** Marks the snackbar action clicked. */
  46. dismissWithAction() {
  47. if (!this._onAction.closed) {
  48. this._dismissedByAction = true;
  49. this._onAction.next();
  50. this._onAction.complete();
  51. this.dismiss();
  52. }
  53. clearTimeout(this._durationTimeoutId);
  54. }
  55. /**
  56. * Marks the snackbar action clicked.
  57. * @deprecated Use `dismissWithAction` instead.
  58. * @breaking-change 8.0.0
  59. */
  60. closeWithAction() {
  61. this.dismissWithAction();
  62. }
  63. /** Dismisses the snack bar after some duration */
  64. _dismissAfter(duration) {
  65. // Note that we need to cap the duration to the maximum value for setTimeout, because
  66. // it'll revert to 1 if somebody passes in something greater (e.g. `Infinity`). See #17234.
  67. this._durationTimeoutId = setTimeout(() => this.dismiss(), Math.min(duration, MAX_TIMEOUT));
  68. }
  69. /** Marks the snackbar as opened */
  70. _open() {
  71. if (!this._afterOpened.closed) {
  72. this._afterOpened.next();
  73. this._afterOpened.complete();
  74. }
  75. }
  76. /** Cleans up the DOM after closing. */
  77. _finishDismiss() {
  78. this._overlayRef.dispose();
  79. if (!this._onAction.closed) {
  80. this._onAction.complete();
  81. }
  82. this._afterDismissed.next({ dismissedByAction: this._dismissedByAction });
  83. this._afterDismissed.complete();
  84. this._dismissedByAction = false;
  85. }
  86. /** Gets an observable that is notified when the snack bar is finished closing. */
  87. afterDismissed() {
  88. return this._afterDismissed;
  89. }
  90. /** Gets an observable that is notified when the snack bar has opened and appeared. */
  91. afterOpened() {
  92. return this.containerInstance._onEnter;
  93. }
  94. /** Gets an observable that is notified when the snack bar action is called. */
  95. onAction() {
  96. return this._onAction;
  97. }
  98. }
  99. /** Injection token that can be used to access the data that was passed in to a snack bar. */
  100. const MAT_SNACK_BAR_DATA = new InjectionToken('MatSnackBarData');
  101. /**
  102. * Configuration used when opening a snack-bar.
  103. */
  104. class MatSnackBarConfig {
  105. constructor() {
  106. /** The politeness level for the MatAriaLiveAnnouncer announcement. */
  107. this.politeness = 'assertive';
  108. /**
  109. * Message to be announced by the LiveAnnouncer. When opening a snackbar without a custom
  110. * component or template, the announcement message will default to the specified message.
  111. */
  112. this.announcementMessage = '';
  113. /** The length of time in milliseconds to wait before automatically dismissing the snack bar. */
  114. this.duration = 0;
  115. /** Data being injected into the child component. */
  116. this.data = null;
  117. /** The horizontal position to place the snack bar. */
  118. this.horizontalPosition = 'center';
  119. /** The vertical position to place the snack bar. */
  120. this.verticalPosition = 'bottom';
  121. }
  122. }
  123. /** Directive that should be applied to the text element to be rendered in the snack bar. */
  124. class MatSnackBarLabel {
  125. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarLabel, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
  126. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: MatSnackBarLabel, selector: "[matSnackBarLabel]", host: { classAttribute: "mat-mdc-snack-bar-label mdc-snackbar__label" }, ngImport: i0 }); }
  127. }
  128. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarLabel, decorators: [{
  129. type: Directive,
  130. args: [{
  131. selector: `[matSnackBarLabel]`,
  132. host: {
  133. 'class': 'mat-mdc-snack-bar-label mdc-snackbar__label',
  134. },
  135. }]
  136. }] });
  137. /** Directive that should be applied to the element containing the snack bar's action buttons. */
  138. class MatSnackBarActions {
  139. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarActions, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
  140. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: MatSnackBarActions, selector: "[matSnackBarActions]", host: { classAttribute: "mat-mdc-snack-bar-actions mdc-snackbar__actions" }, ngImport: i0 }); }
  141. }
  142. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarActions, decorators: [{
  143. type: Directive,
  144. args: [{
  145. selector: `[matSnackBarActions]`,
  146. host: {
  147. 'class': 'mat-mdc-snack-bar-actions mdc-snackbar__actions',
  148. },
  149. }]
  150. }] });
  151. /** Directive that should be applied to each of the snack bar's action buttons. */
  152. class MatSnackBarAction {
  153. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarAction, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
  154. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: MatSnackBarAction, selector: "[matSnackBarAction]", host: { classAttribute: "mat-mdc-snack-bar-action mdc-snackbar__action" }, ngImport: i0 }); }
  155. }
  156. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarAction, decorators: [{
  157. type: Directive,
  158. args: [{
  159. selector: `[matSnackBarAction]`,
  160. host: {
  161. 'class': 'mat-mdc-snack-bar-action mdc-snackbar__action',
  162. },
  163. }]
  164. }] });
  165. class SimpleSnackBar {
  166. constructor(snackBarRef, data) {
  167. this.snackBarRef = snackBarRef;
  168. this.data = data;
  169. }
  170. /** Performs the action on the snack bar. */
  171. action() {
  172. this.snackBarRef.dismissWithAction();
  173. }
  174. /** If the action button should be shown. */
  175. get hasAction() {
  176. return !!this.data.action;
  177. }
  178. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: SimpleSnackBar, deps: [{ token: MatSnackBarRef }, { token: MAT_SNACK_BAR_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
  179. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: SimpleSnackBar, selector: "simple-snack-bar", host: { classAttribute: "mat-mdc-simple-snack-bar" }, exportAs: ["matSnackBar"], ngImport: i0, template: "<div matSnackBarLabel>\n {{data.message}}\n</div>\n\n<div matSnackBarActions *ngIf=\"hasAction\">\n <button mat-button matSnackBarAction (click)=\"action()\">\n {{data.action}}\n </button>\n</div>\n", styles: [".mat-mdc-simple-snack-bar{display:flex}"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: MatSnackBarLabel, selector: "[matSnackBarLabel]" }, { kind: "directive", type: MatSnackBarActions, selector: "[matSnackBarActions]" }, { kind: "directive", type: MatSnackBarAction, selector: "[matSnackBarAction]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  180. }
  181. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: SimpleSnackBar, decorators: [{
  182. type: Component,
  183. args: [{ selector: 'simple-snack-bar', exportAs: 'matSnackBar', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
  184. 'class': 'mat-mdc-simple-snack-bar',
  185. }, template: "<div matSnackBarLabel>\n {{data.message}}\n</div>\n\n<div matSnackBarActions *ngIf=\"hasAction\">\n <button mat-button matSnackBarAction (click)=\"action()\">\n {{data.action}}\n </button>\n</div>\n", styles: [".mat-mdc-simple-snack-bar{display:flex}"] }]
  186. }], ctorParameters: function () { return [{ type: MatSnackBarRef }, { type: undefined, decorators: [{
  187. type: Inject,
  188. args: [MAT_SNACK_BAR_DATA]
  189. }] }]; } });
  190. /**
  191. * Animations used by the Material snack bar.
  192. * @docs-private
  193. */
  194. const matSnackBarAnimations = {
  195. /** Animation that shows and hides a snack bar. */
  196. snackBarState: trigger('state', [
  197. state('void, hidden', style({
  198. transform: 'scale(0.8)',
  199. opacity: 0,
  200. })),
  201. state('visible', style({
  202. transform: 'scale(1)',
  203. opacity: 1,
  204. })),
  205. transition('* => visible', animate('150ms cubic-bezier(0, 0, 0.2, 1)')),
  206. transition('* => void, * => hidden', animate('75ms cubic-bezier(0.4, 0.0, 1, 1)', style({
  207. opacity: 0,
  208. }))),
  209. ]),
  210. };
  211. let uniqueId = 0;
  212. /**
  213. * Base class for snack bar containers.
  214. * @docs-private
  215. */
  216. class _MatSnackBarContainerBase extends BasePortalOutlet {
  217. constructor(_ngZone, _elementRef, _changeDetectorRef, _platform,
  218. /** The snack bar configuration. */
  219. snackBarConfig) {
  220. super();
  221. this._ngZone = _ngZone;
  222. this._elementRef = _elementRef;
  223. this._changeDetectorRef = _changeDetectorRef;
  224. this._platform = _platform;
  225. this.snackBarConfig = snackBarConfig;
  226. this._document = inject(DOCUMENT);
  227. this._trackedModals = new Set();
  228. /** The number of milliseconds to wait before announcing the snack bar's content. */
  229. this._announceDelay = 150;
  230. /** Whether the component has been destroyed. */
  231. this._destroyed = false;
  232. /** Subject for notifying that the snack bar has announced to screen readers. */
  233. this._onAnnounce = new Subject();
  234. /** Subject for notifying that the snack bar has exited from view. */
  235. this._onExit = new Subject();
  236. /** Subject for notifying that the snack bar has finished entering the view. */
  237. this._onEnter = new Subject();
  238. /** The state of the snack bar animations. */
  239. this._animationState = 'void';
  240. /** Unique ID of the aria-live element. */
  241. this._liveElementId = `mat-snack-bar-container-live-${uniqueId++}`;
  242. /**
  243. * Attaches a DOM portal to the snack bar container.
  244. * @deprecated To be turned into a method.
  245. * @breaking-change 10.0.0
  246. */
  247. this.attachDomPortal = (portal) => {
  248. this._assertNotAttached();
  249. const result = this._portalOutlet.attachDomPortal(portal);
  250. this._afterPortalAttached();
  251. return result;
  252. };
  253. // Use aria-live rather than a live role like 'alert' or 'status'
  254. // because NVDA and JAWS have show inconsistent behavior with live roles.
  255. if (snackBarConfig.politeness === 'assertive' && !snackBarConfig.announcementMessage) {
  256. this._live = 'assertive';
  257. }
  258. else if (snackBarConfig.politeness === 'off') {
  259. this._live = 'off';
  260. }
  261. else {
  262. this._live = 'polite';
  263. }
  264. // Only set role for Firefox. Set role based on aria-live because setting role="alert" implies
  265. // aria-live="assertive" which may cause issues if aria-live is set to "polite" above.
  266. if (this._platform.FIREFOX) {
  267. if (this._live === 'polite') {
  268. this._role = 'status';
  269. }
  270. if (this._live === 'assertive') {
  271. this._role = 'alert';
  272. }
  273. }
  274. }
  275. /** Attach a component portal as content to this snack bar container. */
  276. attachComponentPortal(portal) {
  277. this._assertNotAttached();
  278. const result = this._portalOutlet.attachComponentPortal(portal);
  279. this._afterPortalAttached();
  280. return result;
  281. }
  282. /** Attach a template portal as content to this snack bar container. */
  283. attachTemplatePortal(portal) {
  284. this._assertNotAttached();
  285. const result = this._portalOutlet.attachTemplatePortal(portal);
  286. this._afterPortalAttached();
  287. return result;
  288. }
  289. /** Handle end of animations, updating the state of the snackbar. */
  290. onAnimationEnd(event) {
  291. const { fromState, toState } = event;
  292. if ((toState === 'void' && fromState !== 'void') || toState === 'hidden') {
  293. this._completeExit();
  294. }
  295. if (toState === 'visible') {
  296. // Note: we shouldn't use `this` inside the zone callback,
  297. // because it can cause a memory leak.
  298. const onEnter = this._onEnter;
  299. this._ngZone.run(() => {
  300. onEnter.next();
  301. onEnter.complete();
  302. });
  303. }
  304. }
  305. /** Begin animation of snack bar entrance into view. */
  306. enter() {
  307. if (!this._destroyed) {
  308. this._animationState = 'visible';
  309. this._changeDetectorRef.detectChanges();
  310. this._screenReaderAnnounce();
  311. }
  312. }
  313. /** Begin animation of the snack bar exiting from view. */
  314. exit() {
  315. // It's common for snack bars to be opened by random outside calls like HTTP requests or
  316. // errors. Run inside the NgZone to ensure that it functions correctly.
  317. this._ngZone.run(() => {
  318. // Note: this one transitions to `hidden`, rather than `void`, in order to handle the case
  319. // where multiple snack bars are opened in quick succession (e.g. two consecutive calls to
  320. // `MatSnackBar.open`).
  321. this._animationState = 'hidden';
  322. // Mark this element with an 'exit' attribute to indicate that the snackbar has
  323. // been dismissed and will soon be removed from the DOM. This is used by the snackbar
  324. // test harness.
  325. this._elementRef.nativeElement.setAttribute('mat-exit', '');
  326. // If the snack bar hasn't been announced by the time it exits it wouldn't have been open
  327. // long enough to visually read it either, so clear the timeout for announcing.
  328. clearTimeout(this._announceTimeoutId);
  329. });
  330. return this._onExit;
  331. }
  332. /** Makes sure the exit callbacks have been invoked when the element is destroyed. */
  333. ngOnDestroy() {
  334. this._destroyed = true;
  335. this._clearFromModals();
  336. this._completeExit();
  337. }
  338. /**
  339. * Waits for the zone to settle before removing the element. Helps prevent
  340. * errors where we end up removing an element which is in the middle of an animation.
  341. */
  342. _completeExit() {
  343. this._ngZone.onMicrotaskEmpty.pipe(take(1)).subscribe(() => {
  344. this._ngZone.run(() => {
  345. this._onExit.next();
  346. this._onExit.complete();
  347. });
  348. });
  349. }
  350. /**
  351. * Called after the portal contents have been attached. Can be
  352. * used to modify the DOM once it's guaranteed to be in place.
  353. */
  354. _afterPortalAttached() {
  355. const element = this._elementRef.nativeElement;
  356. const panelClasses = this.snackBarConfig.panelClass;
  357. if (panelClasses) {
  358. if (Array.isArray(panelClasses)) {
  359. // Note that we can't use a spread here, because IE doesn't support multiple arguments.
  360. panelClasses.forEach(cssClass => element.classList.add(cssClass));
  361. }
  362. else {
  363. element.classList.add(panelClasses);
  364. }
  365. }
  366. this._exposeToModals();
  367. }
  368. /**
  369. * Some browsers won't expose the accessibility node of the live element if there is an
  370. * `aria-modal` and the live element is outside of it. This method works around the issue by
  371. * pointing the `aria-owns` of all modals to the live element.
  372. */
  373. _exposeToModals() {
  374. // TODO(crisbeto): consider de-duplicating this with the `LiveAnnouncer`.
  375. // Note that the selector here is limited to CDK overlays at the moment in order to reduce the
  376. // section of the DOM we need to look through. This should cover all the cases we support, but
  377. // the selector can be expanded if it turns out to be too narrow.
  378. const id = this._liveElementId;
  379. const modals = this._document.querySelectorAll('body > .cdk-overlay-container [aria-modal="true"]');
  380. for (let i = 0; i < modals.length; i++) {
  381. const modal = modals[i];
  382. const ariaOwns = modal.getAttribute('aria-owns');
  383. this._trackedModals.add(modal);
  384. if (!ariaOwns) {
  385. modal.setAttribute('aria-owns', id);
  386. }
  387. else if (ariaOwns.indexOf(id) === -1) {
  388. modal.setAttribute('aria-owns', ariaOwns + ' ' + id);
  389. }
  390. }
  391. }
  392. /** Clears the references to the live element from any modals it was added to. */
  393. _clearFromModals() {
  394. this._trackedModals.forEach(modal => {
  395. const ariaOwns = modal.getAttribute('aria-owns');
  396. if (ariaOwns) {
  397. const newValue = ariaOwns.replace(this._liveElementId, '').trim();
  398. if (newValue.length > 0) {
  399. modal.setAttribute('aria-owns', newValue);
  400. }
  401. else {
  402. modal.removeAttribute('aria-owns');
  403. }
  404. }
  405. });
  406. this._trackedModals.clear();
  407. }
  408. /** Asserts that no content is already attached to the container. */
  409. _assertNotAttached() {
  410. if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  411. throw Error('Attempting to attach snack bar content after content is already attached');
  412. }
  413. }
  414. /**
  415. * Starts a timeout to move the snack bar content to the live region so screen readers will
  416. * announce it.
  417. */
  418. _screenReaderAnnounce() {
  419. if (!this._announceTimeoutId) {
  420. this._ngZone.runOutsideAngular(() => {
  421. this._announceTimeoutId = setTimeout(() => {
  422. const inertElement = this._elementRef.nativeElement.querySelector('[aria-hidden]');
  423. const liveElement = this._elementRef.nativeElement.querySelector('[aria-live]');
  424. if (inertElement && liveElement) {
  425. // If an element in the snack bar content is focused before being moved
  426. // track it and restore focus after moving to the live region.
  427. let focusedElement = null;
  428. if (this._platform.isBrowser &&
  429. document.activeElement instanceof HTMLElement &&
  430. inertElement.contains(document.activeElement)) {
  431. focusedElement = document.activeElement;
  432. }
  433. inertElement.removeAttribute('aria-hidden');
  434. liveElement.appendChild(inertElement);
  435. focusedElement?.focus();
  436. this._onAnnounce.next();
  437. this._onAnnounce.complete();
  438. }
  439. }, this._announceDelay);
  440. });
  441. }
  442. }
  443. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _MatSnackBarContainerBase, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.Platform }, { token: MatSnackBarConfig }], target: i0.ɵɵFactoryTarget.Directive }); }
  444. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: _MatSnackBarContainerBase, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], usesInheritance: true, ngImport: i0 }); }
  445. }
  446. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _MatSnackBarContainerBase, decorators: [{
  447. type: Directive
  448. }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.Platform }, { type: MatSnackBarConfig }]; }, propDecorators: { _portalOutlet: [{
  449. type: ViewChild,
  450. args: [CdkPortalOutlet, { static: true }]
  451. }] } });
  452. /**
  453. * Internal component that wraps user-provided snack bar content.
  454. * @docs-private
  455. */
  456. class MatSnackBarContainer extends _MatSnackBarContainerBase {
  457. /** Applies the correct CSS class to the label based on its content. */
  458. _afterPortalAttached() {
  459. super._afterPortalAttached();
  460. // Check to see if the attached component or template uses the MDC template structure,
  461. // specifically the MDC label. If not, the container should apply the MDC label class to this
  462. // component's label container, which will apply MDC's label styles to the attached view.
  463. const label = this._label.nativeElement;
  464. const labelClass = 'mdc-snackbar__label';
  465. label.classList.toggle(labelClass, !label.querySelector(`.${labelClass}`));
  466. }
  467. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarContainer, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
  468. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatSnackBarContainer, selector: "mat-snack-bar-container", host: { listeners: { "@state.done": "onAnimationEnd($event)" }, properties: { "@state": "_animationState" }, classAttribute: "mdc-snackbar mat-mdc-snack-bar-container mdc-snackbar--open" }, viewQueries: [{ propertyName: "_label", first: true, predicate: ["label"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"mdc-snackbar__surface\">\n <!--\n This outer label wrapper will have the class `mdc-snackbar__label` applied if\n the attached template/component does not contain it.\n -->\n <div class=\"mat-mdc-snack-bar-label\" #label>\n <!-- Initialy 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\" [attr.id]=\"_liveElementId\"></div>\n </div>\n</div>\n", styles: [".mdc-snackbar{display:none;position:fixed;right:0;bottom:0;left:0;align-items:center;justify-content:center;box-sizing:border-box;pointer-events:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mdc-snackbar--opening,.mdc-snackbar--open,.mdc-snackbar--closing{display:flex}.mdc-snackbar--open .mdc-snackbar__label,.mdc-snackbar--open .mdc-snackbar__actions{visibility:visible}.mdc-snackbar__surface{padding-left:0;padding-right:8px;display:flex;align-items:center;justify-content:flex-start;box-sizing:border-box;transform:scale(0.8);opacity:0}.mdc-snackbar__surface::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media screen and (forced-colors: active){.mdc-snackbar__surface::before{border-color:CanvasText}}[dir=rtl] .mdc-snackbar__surface,.mdc-snackbar__surface[dir=rtl]{padding-left:8px;padding-right:0}.mdc-snackbar--open .mdc-snackbar__surface{transform:scale(1);opacity:1;pointer-events:auto}.mdc-snackbar--closing .mdc-snackbar__surface{transform:scale(1)}.mdc-snackbar__label{padding-left:16px;padding-right:8px;width:100%;flex-grow:1;box-sizing:border-box;margin:0;visibility:hidden;padding-top:14px;padding-bottom:14px}[dir=rtl] .mdc-snackbar__label,.mdc-snackbar__label[dir=rtl]{padding-left:8px;padding-right:16px}.mdc-snackbar__label::before{display:inline;content:attr(data-mdc-snackbar-label-text)}.mdc-snackbar__actions{display:flex;flex-shrink:0;align-items:center;box-sizing:border-box;visibility:hidden}.mdc-snackbar__action+.mdc-snackbar__dismiss{margin-left:8px;margin-right:0}[dir=rtl] .mdc-snackbar__action+.mdc-snackbar__dismiss,.mdc-snackbar__action+.mdc-snackbar__dismiss[dir=rtl]{margin-left:0;margin-right:8px}.mat-mdc-snack-bar-container{margin:8px;--mdc-snackbar-container-shape:4px;position:static}.mat-mdc-snack-bar-container .mdc-snackbar__surface{min-width:344px}@media(max-width: 480px),(max-width: 344px){.mat-mdc-snack-bar-container .mdc-snackbar__surface{min-width:100%}}@media(max-width: 480px),(max-width: 344px){.mat-mdc-snack-bar-container{width:100vw}}.mat-mdc-snack-bar-container .mdc-snackbar__surface{max-width:672px}.mat-mdc-snack-bar-container .mdc-snackbar__surface{box-shadow:0px 3px 5px -1px rgba(0, 0, 0, 0.2), 0px 6px 10px 0px rgba(0, 0, 0, 0.14), 0px 1px 18px 0px rgba(0, 0, 0, 0.12)}.mat-mdc-snack-bar-container .mdc-snackbar__surface{background-color:var(--mdc-snackbar-container-color)}.mat-mdc-snack-bar-container .mdc-snackbar__surface{border-radius:var(--mdc-snackbar-container-shape)}.mat-mdc-snack-bar-container .mdc-snackbar__label{color:var(--mdc-snackbar-supporting-text-color)}.mat-mdc-snack-bar-container .mdc-snackbar__label{font-size:var(--mdc-snackbar-supporting-text-size);font-family:var(--mdc-snackbar-supporting-text-font);font-weight:var(--mdc-snackbar-supporting-text-weight);line-height:var(--mdc-snackbar-supporting-text-line-height)}.mat-mdc-snack-bar-container .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled){color:var(--mat-snack-bar-button-color);--mat-mdc-button-persistent-ripple-color: currentColor}.mat-mdc-snack-bar-container .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled) .mat-ripple-element{background-color:currentColor;opacity:.1}.mat-mdc-snack-bar-container .mdc-snackbar__label::before{display:none}.mat-mdc-snack-bar-handset,.mat-mdc-snack-bar-container,.mat-mdc-snack-bar-label{flex:1 1 auto}.mat-mdc-snack-bar-handset .mdc-snackbar__surface{width:100%}"], dependencies: [{ kind: "directive", type: i3$1.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], animations: [matSnackBarAnimations.snackBarState], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
  469. }
  470. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarContainer, decorators: [{
  471. type: Component,
  472. args: [{ selector: 'mat-snack-bar-container', changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, animations: [matSnackBarAnimations.snackBarState], host: {
  473. 'class': 'mdc-snackbar mat-mdc-snack-bar-container mdc-snackbar--open',
  474. '[@state]': '_animationState',
  475. '(@state.done)': 'onAnimationEnd($event)',
  476. }, template: "<div class=\"mdc-snackbar__surface\">\n <!--\n This outer label wrapper will have the class `mdc-snackbar__label` applied if\n the attached template/component does not contain it.\n -->\n <div class=\"mat-mdc-snack-bar-label\" #label>\n <!-- Initialy 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\" [attr.id]=\"_liveElementId\"></div>\n </div>\n</div>\n", styles: [".mdc-snackbar{display:none;position:fixed;right:0;bottom:0;left:0;align-items:center;justify-content:center;box-sizing:border-box;pointer-events:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mdc-snackbar--opening,.mdc-snackbar--open,.mdc-snackbar--closing{display:flex}.mdc-snackbar--open .mdc-snackbar__label,.mdc-snackbar--open .mdc-snackbar__actions{visibility:visible}.mdc-snackbar__surface{padding-left:0;padding-right:8px;display:flex;align-items:center;justify-content:flex-start;box-sizing:border-box;transform:scale(0.8);opacity:0}.mdc-snackbar__surface::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media screen and (forced-colors: active){.mdc-snackbar__surface::before{border-color:CanvasText}}[dir=rtl] .mdc-snackbar__surface,.mdc-snackbar__surface[dir=rtl]{padding-left:8px;padding-right:0}.mdc-snackbar--open .mdc-snackbar__surface{transform:scale(1);opacity:1;pointer-events:auto}.mdc-snackbar--closing .mdc-snackbar__surface{transform:scale(1)}.mdc-snackbar__label{padding-left:16px;padding-right:8px;width:100%;flex-grow:1;box-sizing:border-box;margin:0;visibility:hidden;padding-top:14px;padding-bottom:14px}[dir=rtl] .mdc-snackbar__label,.mdc-snackbar__label[dir=rtl]{padding-left:8px;padding-right:16px}.mdc-snackbar__label::before{display:inline;content:attr(data-mdc-snackbar-label-text)}.mdc-snackbar__actions{display:flex;flex-shrink:0;align-items:center;box-sizing:border-box;visibility:hidden}.mdc-snackbar__action+.mdc-snackbar__dismiss{margin-left:8px;margin-right:0}[dir=rtl] .mdc-snackbar__action+.mdc-snackbar__dismiss,.mdc-snackbar__action+.mdc-snackbar__dismiss[dir=rtl]{margin-left:0;margin-right:8px}.mat-mdc-snack-bar-container{margin:8px;--mdc-snackbar-container-shape:4px;position:static}.mat-mdc-snack-bar-container .mdc-snackbar__surface{min-width:344px}@media(max-width: 480px),(max-width: 344px){.mat-mdc-snack-bar-container .mdc-snackbar__surface{min-width:100%}}@media(max-width: 480px),(max-width: 344px){.mat-mdc-snack-bar-container{width:100vw}}.mat-mdc-snack-bar-container .mdc-snackbar__surface{max-width:672px}.mat-mdc-snack-bar-container .mdc-snackbar__surface{box-shadow:0px 3px 5px -1px rgba(0, 0, 0, 0.2), 0px 6px 10px 0px rgba(0, 0, 0, 0.14), 0px 1px 18px 0px rgba(0, 0, 0, 0.12)}.mat-mdc-snack-bar-container .mdc-snackbar__surface{background-color:var(--mdc-snackbar-container-color)}.mat-mdc-snack-bar-container .mdc-snackbar__surface{border-radius:var(--mdc-snackbar-container-shape)}.mat-mdc-snack-bar-container .mdc-snackbar__label{color:var(--mdc-snackbar-supporting-text-color)}.mat-mdc-snack-bar-container .mdc-snackbar__label{font-size:var(--mdc-snackbar-supporting-text-size);font-family:var(--mdc-snackbar-supporting-text-font);font-weight:var(--mdc-snackbar-supporting-text-weight);line-height:var(--mdc-snackbar-supporting-text-line-height)}.mat-mdc-snack-bar-container .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled){color:var(--mat-snack-bar-button-color);--mat-mdc-button-persistent-ripple-color: currentColor}.mat-mdc-snack-bar-container .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled) .mat-ripple-element{background-color:currentColor;opacity:.1}.mat-mdc-snack-bar-container .mdc-snackbar__label::before{display:none}.mat-mdc-snack-bar-handset,.mat-mdc-snack-bar-container,.mat-mdc-snack-bar-label{flex:1 1 auto}.mat-mdc-snack-bar-handset .mdc-snackbar__surface{width:100%}"] }]
  477. }], propDecorators: { _label: [{
  478. type: ViewChild,
  479. args: ['label', { static: true }]
  480. }] } });
  481. class MatSnackBarModule {
  482. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
  483. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarModule, declarations: [SimpleSnackBar,
  484. MatSnackBarContainer,
  485. MatSnackBarLabel,
  486. MatSnackBarActions,
  487. MatSnackBarAction], imports: [OverlayModule, PortalModule, CommonModule, MatButtonModule, MatCommonModule], exports: [MatCommonModule,
  488. MatSnackBarContainer,
  489. MatSnackBarLabel,
  490. MatSnackBarActions,
  491. MatSnackBarAction] }); }
  492. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarModule, imports: [OverlayModule, PortalModule, CommonModule, MatButtonModule, MatCommonModule, MatCommonModule] }); }
  493. }
  494. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBarModule, decorators: [{
  495. type: NgModule,
  496. args: [{
  497. imports: [OverlayModule, PortalModule, CommonModule, MatButtonModule, MatCommonModule],
  498. exports: [
  499. MatCommonModule,
  500. MatSnackBarContainer,
  501. MatSnackBarLabel,
  502. MatSnackBarActions,
  503. MatSnackBarAction,
  504. ],
  505. declarations: [
  506. SimpleSnackBar,
  507. MatSnackBarContainer,
  508. MatSnackBarLabel,
  509. MatSnackBarActions,
  510. MatSnackBarAction,
  511. ],
  512. }]
  513. }] });
  514. /** @docs-private */
  515. function MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY() {
  516. return new MatSnackBarConfig();
  517. }
  518. /** Injection token that can be used to specify default snack bar. */
  519. const MAT_SNACK_BAR_DEFAULT_OPTIONS = new InjectionToken('mat-snack-bar-default-options', {
  520. providedIn: 'root',
  521. factory: MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY,
  522. });
  523. class _MatSnackBarBase {
  524. /** Reference to the currently opened snackbar at *any* level. */
  525. get _openedSnackBarRef() {
  526. const parent = this._parentSnackBar;
  527. return parent ? parent._openedSnackBarRef : this._snackBarRefAtThisLevel;
  528. }
  529. set _openedSnackBarRef(value) {
  530. if (this._parentSnackBar) {
  531. this._parentSnackBar._openedSnackBarRef = value;
  532. }
  533. else {
  534. this._snackBarRefAtThisLevel = value;
  535. }
  536. }
  537. constructor(_overlay, _live, _injector, _breakpointObserver, _parentSnackBar, _defaultConfig) {
  538. this._overlay = _overlay;
  539. this._live = _live;
  540. this._injector = _injector;
  541. this._breakpointObserver = _breakpointObserver;
  542. this._parentSnackBar = _parentSnackBar;
  543. this._defaultConfig = _defaultConfig;
  544. /**
  545. * Reference to the current snack bar in the view *at this level* (in the Angular injector tree).
  546. * If there is a parent snack-bar service, all operations should delegate to that parent
  547. * via `_openedSnackBarRef`.
  548. */
  549. this._snackBarRefAtThisLevel = null;
  550. }
  551. /**
  552. * Creates and dispatches a snack bar with a custom component for the content, removing any
  553. * currently opened snack bars.
  554. *
  555. * @param component Component to be instantiated.
  556. * @param config Extra configuration for the snack bar.
  557. */
  558. openFromComponent(component, config) {
  559. return this._attach(component, config);
  560. }
  561. /**
  562. * Creates and dispatches a snack bar with a custom template for the content, removing any
  563. * currently opened snack bars.
  564. *
  565. * @param template Template to be instantiated.
  566. * @param config Extra configuration for the snack bar.
  567. */
  568. openFromTemplate(template, config) {
  569. return this._attach(template, config);
  570. }
  571. /**
  572. * Opens a snackbar with a message and an optional action.
  573. * @param message The message to show in the snackbar.
  574. * @param action The label for the snackbar action.
  575. * @param config Additional configuration options for the snackbar.
  576. */
  577. open(message, action = '', config) {
  578. const _config = { ...this._defaultConfig, ...config };
  579. // Since the user doesn't have access to the component, we can
  580. // override the data to pass in our own message and action.
  581. _config.data = { message, action };
  582. // Since the snack bar has `role="alert"`, we don't
  583. // want to announce the same message twice.
  584. if (_config.announcementMessage === message) {
  585. _config.announcementMessage = undefined;
  586. }
  587. return this.openFromComponent(this.simpleSnackBarComponent, _config);
  588. }
  589. /**
  590. * Dismisses the currently-visible snack bar.
  591. */
  592. dismiss() {
  593. if (this._openedSnackBarRef) {
  594. this._openedSnackBarRef.dismiss();
  595. }
  596. }
  597. ngOnDestroy() {
  598. // Only dismiss the snack bar at the current level on destroy.
  599. if (this._snackBarRefAtThisLevel) {
  600. this._snackBarRefAtThisLevel.dismiss();
  601. }
  602. }
  603. /**
  604. * Attaches the snack bar container component to the overlay.
  605. */
  606. _attachSnackBarContainer(overlayRef, config) {
  607. const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
  608. const injector = Injector.create({
  609. parent: userInjector || this._injector,
  610. providers: [{ provide: MatSnackBarConfig, useValue: config }],
  611. });
  612. const containerPortal = new ComponentPortal(this.snackBarContainerComponent, config.viewContainerRef, injector);
  613. const containerRef = overlayRef.attach(containerPortal);
  614. containerRef.instance.snackBarConfig = config;
  615. return containerRef.instance;
  616. }
  617. /**
  618. * Places a new component or a template as the content of the snack bar container.
  619. */
  620. _attach(content, userConfig) {
  621. const config = { ...new MatSnackBarConfig(), ...this._defaultConfig, ...userConfig };
  622. const overlayRef = this._createOverlay(config);
  623. const container = this._attachSnackBarContainer(overlayRef, config);
  624. const snackBarRef = new MatSnackBarRef(container, overlayRef);
  625. if (content instanceof TemplateRef) {
  626. const portal = new TemplatePortal(content, null, {
  627. $implicit: config.data,
  628. snackBarRef,
  629. });
  630. snackBarRef.instance = container.attachTemplatePortal(portal);
  631. }
  632. else {
  633. const injector = this._createInjector(config, snackBarRef);
  634. const portal = new ComponentPortal(content, undefined, injector);
  635. const contentRef = container.attachComponentPortal(portal);
  636. // We can't pass this via the injector, because the injector is created earlier.
  637. snackBarRef.instance = contentRef.instance;
  638. }
  639. // Subscribe to the breakpoint observer and attach the mat-snack-bar-handset class as
  640. // appropriate. This class is applied to the overlay element because the overlay must expand to
  641. // fill the width of the screen for full width snackbars.
  642. this._breakpointObserver
  643. .observe(Breakpoints.HandsetPortrait)
  644. .pipe(takeUntil(overlayRef.detachments()))
  645. .subscribe(state => {
  646. overlayRef.overlayElement.classList.toggle(this.handsetCssClass, state.matches);
  647. });
  648. if (config.announcementMessage) {
  649. // Wait until the snack bar contents have been announced then deliver this message.
  650. container._onAnnounce.subscribe(() => {
  651. this._live.announce(config.announcementMessage, config.politeness);
  652. });
  653. }
  654. this._animateSnackBar(snackBarRef, config);
  655. this._openedSnackBarRef = snackBarRef;
  656. return this._openedSnackBarRef;
  657. }
  658. /** Animates the old snack bar out and the new one in. */
  659. _animateSnackBar(snackBarRef, config) {
  660. // When the snackbar is dismissed, clear the reference to it.
  661. snackBarRef.afterDismissed().subscribe(() => {
  662. // Clear the snackbar ref if it hasn't already been replaced by a newer snackbar.
  663. if (this._openedSnackBarRef == snackBarRef) {
  664. this._openedSnackBarRef = null;
  665. }
  666. if (config.announcementMessage) {
  667. this._live.clear();
  668. }
  669. });
  670. if (this._openedSnackBarRef) {
  671. // If a snack bar is already in view, dismiss it and enter the
  672. // new snack bar after exit animation is complete.
  673. this._openedSnackBarRef.afterDismissed().subscribe(() => {
  674. snackBarRef.containerInstance.enter();
  675. });
  676. this._openedSnackBarRef.dismiss();
  677. }
  678. else {
  679. // If no snack bar is in view, enter the new snack bar.
  680. snackBarRef.containerInstance.enter();
  681. }
  682. // If a dismiss timeout is provided, set up dismiss based on after the snackbar is opened.
  683. if (config.duration && config.duration > 0) {
  684. snackBarRef.afterOpened().subscribe(() => snackBarRef._dismissAfter(config.duration));
  685. }
  686. }
  687. /**
  688. * Creates a new overlay and places it in the correct location.
  689. * @param config The user-specified snack bar config.
  690. */
  691. _createOverlay(config) {
  692. const overlayConfig = new OverlayConfig();
  693. overlayConfig.direction = config.direction;
  694. let positionStrategy = this._overlay.position().global();
  695. // Set horizontal position.
  696. const isRtl = config.direction === 'rtl';
  697. const isLeft = config.horizontalPosition === 'left' ||
  698. (config.horizontalPosition === 'start' && !isRtl) ||
  699. (config.horizontalPosition === 'end' && isRtl);
  700. const isRight = !isLeft && config.horizontalPosition !== 'center';
  701. if (isLeft) {
  702. positionStrategy.left('0');
  703. }
  704. else if (isRight) {
  705. positionStrategy.right('0');
  706. }
  707. else {
  708. positionStrategy.centerHorizontally();
  709. }
  710. // Set horizontal position.
  711. if (config.verticalPosition === 'top') {
  712. positionStrategy.top('0');
  713. }
  714. else {
  715. positionStrategy.bottom('0');
  716. }
  717. overlayConfig.positionStrategy = positionStrategy;
  718. return this._overlay.create(overlayConfig);
  719. }
  720. /**
  721. * Creates an injector to be used inside of a snack bar component.
  722. * @param config Config that was used to create the snack bar.
  723. * @param snackBarRef Reference to the snack bar.
  724. */
  725. _createInjector(config, snackBarRef) {
  726. const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
  727. return Injector.create({
  728. parent: userInjector || this._injector,
  729. providers: [
  730. { provide: MatSnackBarRef, useValue: snackBarRef },
  731. { provide: MAT_SNACK_BAR_DATA, useValue: config.data },
  732. ],
  733. });
  734. }
  735. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _MatSnackBarBase, deps: [{ token: i1$1.Overlay }, { token: i2$1.LiveAnnouncer }, { token: i0.Injector }, { token: i3$2.BreakpointObserver }, { token: _MatSnackBarBase, optional: true, skipSelf: true }, { token: MAT_SNACK_BAR_DEFAULT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
  736. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _MatSnackBarBase }); }
  737. }
  738. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _MatSnackBarBase, decorators: [{
  739. type: Injectable
  740. }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i2$1.LiveAnnouncer }, { type: i0.Injector }, { type: i3$2.BreakpointObserver }, { type: _MatSnackBarBase, decorators: [{
  741. type: Optional
  742. }, {
  743. type: SkipSelf
  744. }] }, { type: MatSnackBarConfig, decorators: [{
  745. type: Inject,
  746. args: [MAT_SNACK_BAR_DEFAULT_OPTIONS]
  747. }] }]; } });
  748. /**
  749. * Service to dispatch Material Design snack bar messages.
  750. */
  751. class MatSnackBar extends _MatSnackBarBase {
  752. constructor(overlay, live, injector, breakpointObserver, parentSnackBar, defaultConfig) {
  753. super(overlay, live, injector, breakpointObserver, parentSnackBar, defaultConfig);
  754. this.simpleSnackBarComponent = SimpleSnackBar;
  755. this.snackBarContainerComponent = MatSnackBarContainer;
  756. this.handsetCssClass = 'mat-mdc-snack-bar-handset';
  757. }
  758. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBar, deps: [{ token: i1$1.Overlay }, { token: i2$1.LiveAnnouncer }, { token: i0.Injector }, { token: i3$2.BreakpointObserver }, { token: MatSnackBar, optional: true, skipSelf: true }, { token: MAT_SNACK_BAR_DEFAULT_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
  759. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBar, providedIn: MatSnackBarModule }); }
  760. }
  761. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSnackBar, decorators: [{
  762. type: Injectable,
  763. args: [{ providedIn: MatSnackBarModule }]
  764. }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i2$1.LiveAnnouncer }, { type: i0.Injector }, { type: i3$2.BreakpointObserver }, { type: MatSnackBar, decorators: [{
  765. type: Optional
  766. }, {
  767. type: SkipSelf
  768. }] }, { type: MatSnackBarConfig, decorators: [{
  769. type: Inject,
  770. args: [MAT_SNACK_BAR_DEFAULT_OPTIONS]
  771. }] }]; } });
  772. /**
  773. * Generated bundle index. Do not edit.
  774. */
  775. export { MAT_SNACK_BAR_DATA, MAT_SNACK_BAR_DEFAULT_OPTIONS, MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY, MatSnackBar, MatSnackBarAction, MatSnackBarActions, MatSnackBarConfig, MatSnackBarContainer, MatSnackBarLabel, MatSnackBarModule, MatSnackBarRef, SimpleSnackBar, _MatSnackBarBase, _MatSnackBarContainerBase, matSnackBarAnimations };
  776. //# sourceMappingURL=snack-bar.mjs.map