index.d.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. import { AnimationEvent as AnimationEvent_2 } from '@angular/animations';
  2. import { AnimationTriggerMetadata } from '@angular/animations';
  3. import { AriaLivePoliteness } from '@angular/cdk/a11y';
  4. import { BasePortalOutlet } from '@angular/cdk/portal';
  5. import { BreakpointObserver } from '@angular/cdk/layout';
  6. import { CdkPortalOutlet } from '@angular/cdk/portal';
  7. import { ChangeDetectorRef } from '@angular/core';
  8. import { ComponentPortal } from '@angular/cdk/portal';
  9. import { ComponentRef } from '@angular/core';
  10. import { ComponentType } from '@angular/cdk/overlay';
  11. import { Direction } from '@angular/cdk/bidi';
  12. import { DomPortal } from '@angular/cdk/portal';
  13. import { ElementRef } from '@angular/core';
  14. import { EmbeddedViewRef } from '@angular/core';
  15. import * as i0 from '@angular/core';
  16. import * as i4 from '@angular/cdk/overlay';
  17. import * as i5 from '@angular/cdk/portal';
  18. import * as i6 from '@angular/common';
  19. import * as i7 from '@angular/material/button';
  20. import * as i8 from '@angular/material/core';
  21. import { InjectionToken } from '@angular/core';
  22. import { Injector } from '@angular/core';
  23. import { LiveAnnouncer } from '@angular/cdk/a11y';
  24. import { NgZone } from '@angular/core';
  25. import { Observable } from 'rxjs';
  26. import { OnDestroy } from '@angular/core';
  27. import { Overlay } from '@angular/cdk/overlay';
  28. import { OverlayRef } from '@angular/cdk/overlay';
  29. import { Platform } from '@angular/cdk/platform';
  30. import { Subject } from 'rxjs';
  31. import { TemplatePortal } from '@angular/cdk/portal';
  32. import { TemplateRef } from '@angular/core';
  33. import { Type } from '@angular/core';
  34. import { ViewContainerRef } from '@angular/core';
  35. declare namespace i1 {
  36. export {
  37. TextOnlySnackBar,
  38. SimpleSnackBar
  39. }
  40. }
  41. declare namespace i2 {
  42. export {
  43. _MatSnackBarContainerBase,
  44. MatSnackBarContainer
  45. }
  46. }
  47. declare namespace i3 {
  48. export {
  49. MatSnackBarLabel,
  50. MatSnackBarActions,
  51. MatSnackBarAction
  52. }
  53. }
  54. /** Injection token that can be used to access the data that was passed in to a snack bar. */
  55. export declare const MAT_SNACK_BAR_DATA: InjectionToken<any>;
  56. /** Injection token that can be used to specify default snack bar. */
  57. export declare const MAT_SNACK_BAR_DEFAULT_OPTIONS: InjectionToken<MatSnackBarConfig<any>>;
  58. /** @docs-private */
  59. export declare function MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY(): MatSnackBarConfig;
  60. /**
  61. * Service to dispatch Material Design snack bar messages.
  62. */
  63. export declare class MatSnackBar extends _MatSnackBarBase {
  64. protected simpleSnackBarComponent: typeof SimpleSnackBar;
  65. protected snackBarContainerComponent: typeof MatSnackBarContainer;
  66. protected handsetCssClass: string;
  67. constructor(overlay: Overlay, live: LiveAnnouncer, injector: Injector, breakpointObserver: BreakpointObserver, parentSnackBar: MatSnackBar, defaultConfig: MatSnackBarConfig);
  68. static ɵfac: i0.ɵɵFactoryDeclaration<MatSnackBar, [null, null, null, null, { optional: true; skipSelf: true; }, null]>;
  69. static ɵprov: i0.ɵɵInjectableDeclaration<MatSnackBar>;
  70. }
  71. /** Directive that should be applied to each of the snack bar's action buttons. */
  72. export declare class MatSnackBarAction {
  73. static ɵfac: i0.ɵɵFactoryDeclaration<MatSnackBarAction, never>;
  74. static ɵdir: i0.ɵɵDirectiveDeclaration<MatSnackBarAction, "[matSnackBarAction]", never, {}, {}, never, never, false, never>;
  75. }
  76. /** Directive that should be applied to the element containing the snack bar's action buttons. */
  77. export declare class MatSnackBarActions {
  78. static ɵfac: i0.ɵɵFactoryDeclaration<MatSnackBarActions, never>;
  79. static ɵdir: i0.ɵɵDirectiveDeclaration<MatSnackBarActions, "[matSnackBarActions]", never, {}, {}, never, never, false, never>;
  80. }
  81. /**
  82. * Animations used by the Material snack bar.
  83. * @docs-private
  84. */
  85. export declare const matSnackBarAnimations: {
  86. readonly snackBarState: AnimationTriggerMetadata;
  87. };
  88. export declare abstract class _MatSnackBarBase implements OnDestroy {
  89. private _overlay;
  90. private _live;
  91. private _injector;
  92. private _breakpointObserver;
  93. private _parentSnackBar;
  94. private _defaultConfig;
  95. /**
  96. * Reference to the current snack bar in the view *at this level* (in the Angular injector tree).
  97. * If there is a parent snack-bar service, all operations should delegate to that parent
  98. * via `_openedSnackBarRef`.
  99. */
  100. private _snackBarRefAtThisLevel;
  101. /** The component that should be rendered as the snack bar's simple component. */
  102. protected abstract simpleSnackBarComponent: Type<TextOnlySnackBar>;
  103. /** The container component that attaches the provided template or component. */
  104. protected abstract snackBarContainerComponent: Type<_MatSnackBarContainerBase>;
  105. /** The CSS class to apply for handset mode. */
  106. protected abstract handsetCssClass: string;
  107. /** Reference to the currently opened snackbar at *any* level. */
  108. get _openedSnackBarRef(): MatSnackBarRef<any> | null;
  109. set _openedSnackBarRef(value: MatSnackBarRef<any> | null);
  110. constructor(_overlay: Overlay, _live: LiveAnnouncer, _injector: Injector, _breakpointObserver: BreakpointObserver, _parentSnackBar: _MatSnackBarBase, _defaultConfig: MatSnackBarConfig);
  111. /**
  112. * Creates and dispatches a snack bar with a custom component for the content, removing any
  113. * currently opened snack bars.
  114. *
  115. * @param component Component to be instantiated.
  116. * @param config Extra configuration for the snack bar.
  117. */
  118. openFromComponent<T, D = any>(component: ComponentType<T>, config?: MatSnackBarConfig<D>): MatSnackBarRef<T>;
  119. /**
  120. * Creates and dispatches a snack bar with a custom template for the content, removing any
  121. * currently opened snack bars.
  122. *
  123. * @param template Template to be instantiated.
  124. * @param config Extra configuration for the snack bar.
  125. */
  126. openFromTemplate(template: TemplateRef<any>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<any>>;
  127. /**
  128. * Opens a snackbar with a message and an optional action.
  129. * @param message The message to show in the snackbar.
  130. * @param action The label for the snackbar action.
  131. * @param config Additional configuration options for the snackbar.
  132. */
  133. open(message: string, action?: string, config?: MatSnackBarConfig): MatSnackBarRef<TextOnlySnackBar>;
  134. /**
  135. * Dismisses the currently-visible snack bar.
  136. */
  137. dismiss(): void;
  138. ngOnDestroy(): void;
  139. /**
  140. * Attaches the snack bar container component to the overlay.
  141. */
  142. private _attachSnackBarContainer;
  143. /**
  144. * Places a new component or a template as the content of the snack bar container.
  145. */
  146. private _attach;
  147. /** Animates the old snack bar out and the new one in. */
  148. private _animateSnackBar;
  149. /**
  150. * Creates a new overlay and places it in the correct location.
  151. * @param config The user-specified snack bar config.
  152. */
  153. private _createOverlay;
  154. /**
  155. * Creates an injector to be used inside of a snack bar component.
  156. * @param config Config that was used to create the snack bar.
  157. * @param snackBarRef Reference to the snack bar.
  158. */
  159. private _createInjector;
  160. static ɵfac: i0.ɵɵFactoryDeclaration<_MatSnackBarBase, [null, null, null, null, { optional: true; skipSelf: true; }, null]>;
  161. static ɵprov: i0.ɵɵInjectableDeclaration<_MatSnackBarBase>;
  162. }
  163. /**
  164. * Configuration used when opening a snack-bar.
  165. */
  166. export declare class MatSnackBarConfig<D = any> {
  167. /** The politeness level for the MatAriaLiveAnnouncer announcement. */
  168. politeness?: AriaLivePoliteness;
  169. /**
  170. * Message to be announced by the LiveAnnouncer. When opening a snackbar without a custom
  171. * component or template, the announcement message will default to the specified message.
  172. */
  173. announcementMessage?: string;
  174. /**
  175. * The view container that serves as the parent for the snackbar for the purposes of dependency
  176. * injection. Note: this does not affect where the snackbar is inserted in the DOM.
  177. */
  178. viewContainerRef?: ViewContainerRef;
  179. /** The length of time in milliseconds to wait before automatically dismissing the snack bar. */
  180. duration?: number;
  181. /** Extra CSS classes to be added to the snack bar container. */
  182. panelClass?: string | string[];
  183. /** Text layout direction for the snack bar. */
  184. direction?: Direction;
  185. /** Data being injected into the child component. */
  186. data?: D | null;
  187. /** The horizontal position to place the snack bar. */
  188. horizontalPosition?: MatSnackBarHorizontalPosition;
  189. /** The vertical position to place the snack bar. */
  190. verticalPosition?: MatSnackBarVerticalPosition;
  191. }
  192. /**
  193. * Internal component that wraps user-provided snack bar content.
  194. * @docs-private
  195. */
  196. export declare class MatSnackBarContainer extends _MatSnackBarContainerBase {
  197. /**
  198. * Element that will have the `mdc-snackbar__label` class applied if the attached component
  199. * or template does not have it. This ensures that the appropriate structure, typography, and
  200. * color is applied to the attached view.
  201. */
  202. _label: ElementRef;
  203. /** Applies the correct CSS class to the label based on its content. */
  204. protected _afterPortalAttached(): void;
  205. static ɵfac: i0.ɵɵFactoryDeclaration<MatSnackBarContainer, never>;
  206. static ɵcmp: i0.ɵɵComponentDeclaration<MatSnackBarContainer, "mat-snack-bar-container", never, {}, {}, never, never, false, never>;
  207. }
  208. /**
  209. * Base class for snack bar containers.
  210. * @docs-private
  211. */
  212. export declare abstract class _MatSnackBarContainerBase extends BasePortalOutlet implements OnDestroy {
  213. private _ngZone;
  214. protected _elementRef: ElementRef<HTMLElement>;
  215. private _changeDetectorRef;
  216. private _platform;
  217. /** The snack bar configuration. */
  218. snackBarConfig: MatSnackBarConfig;
  219. private _document;
  220. private _trackedModals;
  221. /** The number of milliseconds to wait before announcing the snack bar's content. */
  222. private readonly _announceDelay;
  223. /** The timeout for announcing the snack bar's content. */
  224. private _announceTimeoutId;
  225. /** Whether the component has been destroyed. */
  226. private _destroyed;
  227. /** The portal outlet inside of this container into which the snack bar content will be loaded. */
  228. _portalOutlet: CdkPortalOutlet;
  229. /** Subject for notifying that the snack bar has announced to screen readers. */
  230. readonly _onAnnounce: Subject<void>;
  231. /** Subject for notifying that the snack bar has exited from view. */
  232. readonly _onExit: Subject<void>;
  233. /** Subject for notifying that the snack bar has finished entering the view. */
  234. readonly _onEnter: Subject<void>;
  235. /** The state of the snack bar animations. */
  236. _animationState: string;
  237. /** aria-live value for the live region. */
  238. _live: AriaLivePoliteness;
  239. /**
  240. * Role of the live region. This is only for Firefox as there is a known issue where Firefox +
  241. * JAWS does not read out aria-live message.
  242. */
  243. _role?: 'status' | 'alert';
  244. /** Unique ID of the aria-live element. */
  245. readonly _liveElementId: string;
  246. constructor(_ngZone: NgZone, _elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, _platform: Platform,
  247. /** The snack bar configuration. */
  248. snackBarConfig: MatSnackBarConfig);
  249. /** Attach a component portal as content to this snack bar container. */
  250. attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>;
  251. /** Attach a template portal as content to this snack bar container. */
  252. attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
  253. /**
  254. * Attaches a DOM portal to the snack bar container.
  255. * @deprecated To be turned into a method.
  256. * @breaking-change 10.0.0
  257. */
  258. attachDomPortal: (portal: DomPortal) => void;
  259. /** Handle end of animations, updating the state of the snackbar. */
  260. onAnimationEnd(event: AnimationEvent_2): void;
  261. /** Begin animation of snack bar entrance into view. */
  262. enter(): void;
  263. /** Begin animation of the snack bar exiting from view. */
  264. exit(): Observable<void>;
  265. /** Makes sure the exit callbacks have been invoked when the element is destroyed. */
  266. ngOnDestroy(): void;
  267. /**
  268. * Waits for the zone to settle before removing the element. Helps prevent
  269. * errors where we end up removing an element which is in the middle of an animation.
  270. */
  271. private _completeExit;
  272. /**
  273. * Called after the portal contents have been attached. Can be
  274. * used to modify the DOM once it's guaranteed to be in place.
  275. */
  276. protected _afterPortalAttached(): void;
  277. /**
  278. * Some browsers won't expose the accessibility node of the live element if there is an
  279. * `aria-modal` and the live element is outside of it. This method works around the issue by
  280. * pointing the `aria-owns` of all modals to the live element.
  281. */
  282. private _exposeToModals;
  283. /** Clears the references to the live element from any modals it was added to. */
  284. private _clearFromModals;
  285. /** Asserts that no content is already attached to the container. */
  286. private _assertNotAttached;
  287. /**
  288. * Starts a timeout to move the snack bar content to the live region so screen readers will
  289. * announce it.
  290. */
  291. private _screenReaderAnnounce;
  292. static ɵfac: i0.ɵɵFactoryDeclaration<_MatSnackBarContainerBase, never>;
  293. static ɵdir: i0.ɵɵDirectiveDeclaration<_MatSnackBarContainerBase, never, never, {}, {}, never, never, false, never>;
  294. }
  295. /** Event that is emitted when a snack bar is dismissed. */
  296. export declare interface MatSnackBarDismiss {
  297. /** Whether the snack bar was dismissed using the action button. */
  298. dismissedByAction: boolean;
  299. }
  300. /** Possible values for horizontalPosition on MatSnackBarConfig. */
  301. export declare type MatSnackBarHorizontalPosition = 'start' | 'center' | 'end' | 'left' | 'right';
  302. /** Directive that should be applied to the text element to be rendered in the snack bar. */
  303. export declare class MatSnackBarLabel {
  304. static ɵfac: i0.ɵɵFactoryDeclaration<MatSnackBarLabel, never>;
  305. static ɵdir: i0.ɵɵDirectiveDeclaration<MatSnackBarLabel, "[matSnackBarLabel]", never, {}, {}, never, never, false, never>;
  306. }
  307. export declare class MatSnackBarModule {
  308. static ɵfac: i0.ɵɵFactoryDeclaration<MatSnackBarModule, never>;
  309. static ɵmod: i0.ɵɵNgModuleDeclaration<MatSnackBarModule, [typeof i1.SimpleSnackBar, typeof i2.MatSnackBarContainer, typeof i3.MatSnackBarLabel, typeof i3.MatSnackBarActions, typeof i3.MatSnackBarAction], [typeof i4.OverlayModule, typeof i5.PortalModule, typeof i6.CommonModule, typeof i7.MatButtonModule, typeof i8.MatCommonModule], [typeof i8.MatCommonModule, typeof i2.MatSnackBarContainer, typeof i3.MatSnackBarLabel, typeof i3.MatSnackBarActions, typeof i3.MatSnackBarAction]>;
  310. static ɵinj: i0.ɵɵInjectorDeclaration<MatSnackBarModule>;
  311. }
  312. /**
  313. * Reference to a snack bar dispatched from the snack bar service.
  314. */
  315. export declare class MatSnackBarRef<T> {
  316. private _overlayRef;
  317. /** The instance of the component making up the content of the snack bar. */
  318. instance: T;
  319. /**
  320. * The instance of the component making up the content of the snack bar.
  321. * @docs-private
  322. */
  323. containerInstance: _MatSnackBarContainerBase;
  324. /** Subject for notifying the user that the snack bar has been dismissed. */
  325. private readonly _afterDismissed;
  326. /** Subject for notifying the user that the snack bar has opened and appeared. */
  327. private readonly _afterOpened;
  328. /** Subject for notifying the user that the snack bar action was called. */
  329. private readonly _onAction;
  330. /**
  331. * Timeout ID for the duration setTimeout call. Used to clear the timeout if the snackbar is
  332. * dismissed before the duration passes.
  333. */
  334. private _durationTimeoutId;
  335. /** Whether the snack bar was dismissed using the action button. */
  336. private _dismissedByAction;
  337. constructor(containerInstance: _MatSnackBarContainerBase, _overlayRef: OverlayRef);
  338. /** Dismisses the snack bar. */
  339. dismiss(): void;
  340. /** Marks the snackbar action clicked. */
  341. dismissWithAction(): void;
  342. /**
  343. * Marks the snackbar action clicked.
  344. * @deprecated Use `dismissWithAction` instead.
  345. * @breaking-change 8.0.0
  346. */
  347. closeWithAction(): void;
  348. /** Dismisses the snack bar after some duration */
  349. _dismissAfter(duration: number): void;
  350. /** Marks the snackbar as opened */
  351. _open(): void;
  352. /** Cleans up the DOM after closing. */
  353. private _finishDismiss;
  354. /** Gets an observable that is notified when the snack bar is finished closing. */
  355. afterDismissed(): Observable<MatSnackBarDismiss>;
  356. /** Gets an observable that is notified when the snack bar has opened and appeared. */
  357. afterOpened(): Observable<void>;
  358. /** Gets an observable that is notified when the snack bar action is called. */
  359. onAction(): Observable<void>;
  360. }
  361. /** Possible values for verticalPosition on MatSnackBarConfig. */
  362. export declare type MatSnackBarVerticalPosition = 'top' | 'bottom';
  363. export declare class SimpleSnackBar implements TextOnlySnackBar {
  364. snackBarRef: MatSnackBarRef<SimpleSnackBar>;
  365. data: {
  366. message: string;
  367. action: string;
  368. };
  369. constructor(snackBarRef: MatSnackBarRef<SimpleSnackBar>, data: {
  370. message: string;
  371. action: string;
  372. });
  373. /** Performs the action on the snack bar. */
  374. action(): void;
  375. /** If the action button should be shown. */
  376. get hasAction(): boolean;
  377. static ɵfac: i0.ɵɵFactoryDeclaration<SimpleSnackBar, never>;
  378. static ɵcmp: i0.ɵɵComponentDeclaration<SimpleSnackBar, "simple-snack-bar", ["matSnackBar"], {}, {}, never, never, false, never>;
  379. }
  380. /**
  381. * Interface for a simple snack bar component that has a message and a single action.
  382. */
  383. export declare interface TextOnlySnackBar {
  384. data: {
  385. message: string;
  386. action: string;
  387. };
  388. snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
  389. action: () => void;
  390. hasAction: boolean;
  391. }
  392. export { }