dialog.d.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 { Overlay, OverlayContainer, ScrollStrategy } from '@angular/cdk/overlay';
  9. import { ComponentType } from '@angular/cdk/portal';
  10. import { Location } from '@angular/common';
  11. import { InjectionToken, Injector, OnDestroy, TemplateRef } from '@angular/core';
  12. import { Observable, Subject } from 'rxjs';
  13. import { MatDialogConfig } from './dialog-config';
  14. import { MatDialogRef } from './dialog-ref';
  15. /** Injection token that can be used to access the data that was passed in to a dialog. */
  16. export declare const MAT_DIALOG_DATA: InjectionToken<any>;
  17. /** Injection token that can be used to specify default dialog options. */
  18. export declare const MAT_DIALOG_DEFAULT_OPTIONS: InjectionToken<MatDialogConfig<any>>;
  19. /** Injection token that determines the scroll handling while the dialog is open. */
  20. export declare const MAT_DIALOG_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
  21. /** @docs-private */
  22. export declare function MAT_DIALOG_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
  23. /** @docs-private */
  24. export declare function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => ScrollStrategy;
  25. /** @docs-private */
  26. export declare const MAT_DIALOG_SCROLL_STRATEGY_PROVIDER: {
  27. provide: InjectionToken<() => ScrollStrategy>;
  28. deps: (typeof Overlay)[];
  29. useFactory: typeof MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY;
  30. };
  31. /**
  32. * Service to open Material Design modal dialogs.
  33. */
  34. export declare class MatDialog implements OnDestroy {
  35. private _overlay;
  36. private _injector;
  37. private _location;
  38. private _defaultOptions;
  39. private _parentDialog;
  40. private _overlayContainer;
  41. private _openDialogsAtThisLevel;
  42. private readonly _afterAllClosedAtThisLevel;
  43. private readonly _afterOpenedAtThisLevel;
  44. private _ariaHiddenElements;
  45. private _scrollStrategy;
  46. /** Keeps track of the currently-open dialogs. */
  47. readonly openDialogs: MatDialogRef<any>[];
  48. /** Stream that emits when a dialog has been opened. */
  49. readonly afterOpened: Subject<MatDialogRef<any>>;
  50. /**
  51. * Stream that emits when a dialog has been opened.
  52. * @deprecated Use `afterOpened` instead.
  53. * @breaking-change 8.0.0
  54. */
  55. readonly afterOpen: Subject<MatDialogRef<any>>;
  56. readonly _afterAllClosed: Subject<void>;
  57. /**
  58. * Stream that emits when all open dialog have finished closing.
  59. * Will emit on subscribe if there are no open dialogs to begin with.
  60. */
  61. readonly afterAllClosed: Observable<void>;
  62. constructor(_overlay: Overlay, _injector: Injector, _location: Location, _defaultOptions: MatDialogConfig, scrollStrategy: any, _parentDialog: MatDialog, _overlayContainer: OverlayContainer);
  63. /**
  64. * Opens a modal dialog containing the given component.
  65. * @param componentOrTemplateRef Type of the component to load into the dialog,
  66. * or a TemplateRef to instantiate as the dialog content.
  67. * @param config Extra configuration options.
  68. * @returns Reference to the newly-opened dialog.
  69. */
  70. open<T, D = any, R = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>, config?: MatDialogConfig<D>): MatDialogRef<T, R>;
  71. /**
  72. * Closes all of the currently-open dialogs.
  73. */
  74. closeAll(): void;
  75. /**
  76. * Finds an open dialog by its id.
  77. * @param id ID to use when looking up the dialog.
  78. */
  79. getDialogById(id: string): MatDialogRef<any> | undefined;
  80. ngOnDestroy(): void;
  81. /**
  82. * Creates the overlay into which the dialog will be loaded.
  83. * @param config The dialog configuration.
  84. * @returns A promise resolving to the OverlayRef for the created overlay.
  85. */
  86. private _createOverlay;
  87. /**
  88. * Creates an overlay config from a dialog config.
  89. * @param dialogConfig The dialog configuration.
  90. * @returns The overlay configuration.
  91. */
  92. private _getOverlayConfig;
  93. /**
  94. * Attaches an MatDialogContainer to a dialog's already-created overlay.
  95. * @param overlay Reference to the dialog's underlying overlay.
  96. * @param config The dialog configuration.
  97. * @returns A promise resolving to a ComponentRef for the attached container.
  98. */
  99. private _attachDialogContainer;
  100. /**
  101. * Attaches the user-provided component to the already-created MatDialogContainer.
  102. * @param componentOrTemplateRef The type of component being loaded into the dialog,
  103. * or a TemplateRef to instantiate as the content.
  104. * @param dialogContainer Reference to the wrapping MatDialogContainer.
  105. * @param overlayRef Reference to the overlay in which the dialog resides.
  106. * @param config The dialog configuration.
  107. * @returns A promise resolving to the MatDialogRef that should be returned to the user.
  108. */
  109. private _attachDialogContent;
  110. /**
  111. * Creates a custom injector to be used inside the dialog. This allows a component loaded inside
  112. * of a dialog to close itself and, optionally, to return a value.
  113. * @param config Config object that is used to construct the dialog.
  114. * @param dialogRef Reference to the dialog.
  115. * @param container Dialog container element that wraps all of the contents.
  116. * @returns The custom injector that can be used inside the dialog.
  117. */
  118. private _createInjector;
  119. /**
  120. * Removes a dialog from the array of open dialogs.
  121. * @param dialogRef Dialog to be removed.
  122. */
  123. private _removeOpenDialog;
  124. /**
  125. * Hides all of the content that isn't an overlay from assistive technology.
  126. */
  127. private _hideNonDialogContentFromAssistiveTechnology;
  128. /** Closes all of the dialogs in an array. */
  129. private _closeDialogs;
  130. }