snack-bar.mjs 48 KB

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