snack-bar.d.ts 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { LiveAnnouncer } from '@angular/cdk/a11y';
  9. import { BreakpointObserver } from '@angular/cdk/layout';
  10. import { Overlay } from '@angular/cdk/overlay';
  11. import { ComponentType } from '@angular/cdk/portal';
  12. import { EmbeddedViewRef, InjectionToken, Injector, TemplateRef, OnDestroy } from '@angular/core';
  13. import { SimpleSnackBar } from './simple-snack-bar';
  14. import { MatSnackBarConfig } from './snack-bar-config';
  15. import { MatSnackBarRef } from './snack-bar-ref';
  16. /** Injection token that can be used to specify default snack bar. */
  17. export declare const MAT_SNACK_BAR_DEFAULT_OPTIONS: InjectionToken<MatSnackBarConfig<any>>;
  18. /** @docs-private */
  19. export declare function MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY(): MatSnackBarConfig;
  20. /**
  21. * Service to dispatch Material Design snack bar messages.
  22. */
  23. export declare class MatSnackBar implements OnDestroy {
  24. private _overlay;
  25. private _live;
  26. private _injector;
  27. private _breakpointObserver;
  28. private _parentSnackBar;
  29. private _defaultConfig;
  30. /**
  31. * Reference to the current snack bar in the view *at this level* (in the Angular injector tree).
  32. * If there is a parent snack-bar service, all operations should delegate to that parent
  33. * via `_openedSnackBarRef`.
  34. */
  35. private _snackBarRefAtThisLevel;
  36. /** Reference to the currently opened snackbar at *any* level. */
  37. _openedSnackBarRef: MatSnackBarRef<any> | null;
  38. constructor(_overlay: Overlay, _live: LiveAnnouncer, _injector: Injector, _breakpointObserver: BreakpointObserver, _parentSnackBar: MatSnackBar, _defaultConfig: MatSnackBarConfig);
  39. /**
  40. * Creates and dispatches a snack bar with a custom component for the content, removing any
  41. * currently opened snack bars.
  42. *
  43. * @param component Component to be instantiated.
  44. * @param config Extra configuration for the snack bar.
  45. */
  46. openFromComponent<T>(component: ComponentType<T>, config?: MatSnackBarConfig): MatSnackBarRef<T>;
  47. /**
  48. * Creates and dispatches a snack bar with a custom template for the content, removing any
  49. * currently opened snack bars.
  50. *
  51. * @param template Template to be instantiated.
  52. * @param config Extra configuration for the snack bar.
  53. */
  54. openFromTemplate(template: TemplateRef<any>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<any>>;
  55. /**
  56. * Opens a snackbar with a message and an optional action.
  57. * @param message The message to show in the snackbar.
  58. * @param action The label for the snackbar action.
  59. * @param config Additional configuration options for the snackbar.
  60. */
  61. open(message: string, action?: string, config?: MatSnackBarConfig): MatSnackBarRef<SimpleSnackBar>;
  62. /**
  63. * Dismisses the currently-visible snack bar.
  64. */
  65. dismiss(): void;
  66. ngOnDestroy(): void;
  67. /**
  68. * Attaches the snack bar container component to the overlay.
  69. */
  70. private _attachSnackBarContainer;
  71. /**
  72. * Places a new component or a template as the content of the snack bar container.
  73. */
  74. private _attach;
  75. /** Animates the old snack bar out and the new one in. */
  76. private _animateSnackBar;
  77. /**
  78. * Creates a new overlay and places it in the correct location.
  79. * @param config The user-specified snack bar config.
  80. */
  81. private _createOverlay;
  82. /**
  83. * Creates an injector to be used inside of a snack bar component.
  84. * @param config Config that was used to create the snack bar.
  85. * @param snackBarRef Reference to the snack bar.
  86. */
  87. private _createInjector;
  88. }