@angular-mdc/web
Version:
67 lines (66 loc) • 2.86 kB
TypeScript
import { InjectionToken, Injector, OnDestroy } from '@angular/core';
import { Overlay } from '@angular/cdk/overlay';
import { ComponentType } from '@angular/cdk/portal';
import { MdcSnackbarRef } from './snackbar-ref';
import { MdcSnackbarComponent } from './snackbar.component';
import { MdcSnackbarConfig } from './snackbar-config';
/** Injection token that can be used to specify default snackbar. */
export declare const MDC_SNACKBAR_DEFAULT_OPTIONS: InjectionToken<MdcSnackbarConfig<any>>;
/** @docs-private */
export declare function MDC_SNACKBAR_DEFAULT_OPTIONS_FACTORY(): MdcSnackbarConfig;
export declare class MdcSnackbar implements OnDestroy {
private _overlay;
private _injector;
private _parentSnackBar;
private _defaultConfig;
/**
* Reference to the current snackbar in the view *at this level* (in the Angular injector tree).
* If there is a parent snack-bar service, all operations should delegate to that parent
* via `_openedSnackBarRef`.
*/
private _snackBarRefAtThisLevel;
/** Reference to the currently opened snackbar at *any* level. */
get _openedSnackbarRef(): MdcSnackbarRef<any> | null;
set _openedSnackbarRef(value: MdcSnackbarRef<any> | null);
constructor(_overlay: Overlay, _injector: Injector, _parentSnackBar: MdcSnackbar, _defaultConfig: MdcSnackbarConfig);
/**
* Creates and dispatches a snackbar with a custom component for the content, removing any
* currently opened snackbars.
*
* @param component Component to be instantiated.
* @param config Extra configuration for the snackbar.
*/
openFromComponent<T>(component: ComponentType<T>, config?: MdcSnackbarConfig): MdcSnackbarRef<T>;
/**
* Opens a snackbar with a message and an optional action.
* @param message Message text.
* @param action The label for the snackbar action.
* @param config Additional configuration options for the snackbar.
*/
open(message: string, action?: string, config?: MdcSnackbarConfig): MdcSnackbarRef<MdcSnackbarComponent>;
/**
* Dismisses the currently-visible snackbar.
*/
dismiss(): void;
ngOnDestroy(): void;
/**
* Attaches the snackbar container component to the overlay.
*/
private _attachSnackbarContainer;
/**
* Places a new component or a template as the content of the snackbar container.
*/
private _attach;
private _loadListeners;
/**
* Creates a new overlay and places it in the correct location.
* @param config The user-specified snackbar config.
*/
private _createOverlay;
/**
* Creates an injector to be used inside of a snackbar component.
* @param config Config that was used to create the snackbar.
* @param snackbarRef Reference to the snackbar.
*/
private _createInjector;
}