index.d.ts 15 KB

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