dialog-container.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 { ComponentRef, ElementRef, EmbeddedViewRef, EventEmitter, ChangeDetectorRef } from '@angular/core';
  9. import { AnimationEvent } from '@angular/animations';
  10. import { BasePortalOutlet, ComponentPortal, CdkPortalOutlet, TemplatePortal } from '@angular/cdk/portal';
  11. import { FocusTrapFactory } from '@angular/cdk/a11y';
  12. import { MatDialogConfig } from './dialog-config';
  13. /**
  14. * Throws an exception for the case when a ComponentPortal is
  15. * attached to a DomPortalOutlet without an origin.
  16. * @docs-private
  17. */
  18. export declare function throwMatDialogContentAlreadyAttachedError(): void;
  19. /**
  20. * Internal component that wraps user-provided dialog content.
  21. * Animation is based on https://material.io/guidelines/motion/choreography.html.
  22. * @docs-private
  23. */
  24. export declare class MatDialogContainer extends BasePortalOutlet {
  25. private _elementRef;
  26. private _focusTrapFactory;
  27. private _changeDetectorRef;
  28. private _document;
  29. /** The dialog configuration. */
  30. _config: MatDialogConfig;
  31. /** The portal outlet inside of this container into which the dialog content will be loaded. */
  32. _portalOutlet: CdkPortalOutlet;
  33. /** The class that traps and manages focus within the dialog. */
  34. private _focusTrap;
  35. /** Element that was focused before the dialog was opened. Save this to restore upon close. */
  36. private _elementFocusedBeforeDialogWasOpened;
  37. /** State of the dialog animation. */
  38. _state: 'void' | 'enter' | 'exit';
  39. /** Emits when an animation state changes. */
  40. _animationStateChanged: EventEmitter<AnimationEvent>;
  41. /** ID of the element that should be considered as the dialog's label. */
  42. _ariaLabelledBy: string | null;
  43. /** ID for the container DOM element. */
  44. _id: string;
  45. constructor(_elementRef: ElementRef, _focusTrapFactory: FocusTrapFactory, _changeDetectorRef: ChangeDetectorRef, _document: any,
  46. /** The dialog configuration. */
  47. _config: MatDialogConfig);
  48. /**
  49. * Attach a ComponentPortal as content to this dialog container.
  50. * @param portal Portal to be attached as the dialog content.
  51. */
  52. attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T>;
  53. /**
  54. * Attach a TemplatePortal as content to this dialog container.
  55. * @param portal Portal to be attached as the dialog content.
  56. */
  57. attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
  58. /** Moves the focus inside the focus trap. */
  59. private _trapFocus;
  60. /** Restores focus to the element that was focused before the dialog opened. */
  61. private _restoreFocus;
  62. /** Saves a reference to the element that was focused before the dialog was opened. */
  63. private _savePreviouslyFocusedElement;
  64. /** Callback, invoked whenever an animation on the host completes. */
  65. _onAnimationDone(event: AnimationEvent): void;
  66. /** Callback, invoked when an animation on the host starts. */
  67. _onAnimationStart(event: AnimationEvent): void;
  68. /** Starts the dialog exit animation. */
  69. _startExitAnimation(): void;
  70. }