tab-body.d.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 { ChangeDetectorRef, EventEmitter, OnDestroy, OnInit, ElementRef, ComponentFactoryResolver, ViewContainerRef } from '@angular/core';
  9. import { AnimationEvent } from '@angular/animations';
  10. import { TemplatePortal, CdkPortalOutlet, PortalHostDirective } from '@angular/cdk/portal';
  11. import { Directionality, Direction } from '@angular/cdk/bidi';
  12. import { Subject } from 'rxjs';
  13. /**
  14. * These position states are used internally as animation states for the tab body. Setting the
  15. * position state to left, right, or center will transition the tab body from its current
  16. * position to its respective state. If there is not current position (void, in the case of a new
  17. * tab body), then there will be no transition animation to its state.
  18. *
  19. * In the case of a new tab body that should immediately be centered with an animating transition,
  20. * then left-origin-center or right-origin-center can be used, which will use left or right as its
  21. * psuedo-prior state.
  22. */
  23. export declare type MatTabBodyPositionState = 'left' | 'center' | 'right' | 'left-origin-center' | 'right-origin-center';
  24. /**
  25. * The origin state is an internally used state that is set on a new tab body indicating if it
  26. * began to the left or right of the prior selected index. For example, if the selected index was
  27. * set to 1, and a new tab is created and selected at index 2, then the tab body would have an
  28. * origin of right because its index was greater than the prior selected index.
  29. */
  30. export declare type MatTabBodyOriginState = 'left' | 'right';
  31. /**
  32. * The portal host directive for the contents of the tab.
  33. * @docs-private
  34. */
  35. export declare class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestroy {
  36. private _host;
  37. /** Subscription to events for when the tab body begins centering. */
  38. private _centeringSub;
  39. /** Subscription to events for when the tab body finishes leaving from center position. */
  40. private _leavingSub;
  41. constructor(componentFactoryResolver: ComponentFactoryResolver, viewContainerRef: ViewContainerRef, _host: MatTabBody);
  42. /** Set initial visibility or set up subscription for changing visibility. */
  43. ngOnInit(): void;
  44. /** Clean up centering subscription. */
  45. ngOnDestroy(): void;
  46. }
  47. /**
  48. * Wrapper for the contents of a tab.
  49. * @docs-private
  50. */
  51. export declare class MatTabBody implements OnInit, OnDestroy {
  52. private _elementRef;
  53. private _dir;
  54. /** Current position of the tab-body in the tab-group. Zero means that the tab is visible. */
  55. private _positionIndex;
  56. /** Subscription to the directionality change observable. */
  57. private _dirChangeSubscription;
  58. /** Tab body position state. Used by the animation trigger for the current state. */
  59. _position: MatTabBodyPositionState;
  60. /** Emits when an animation on the tab is complete. */
  61. _translateTabComplete: Subject<AnimationEvent>;
  62. /** Event emitted when the tab begins to animate towards the center as the active tab. */
  63. readonly _onCentering: EventEmitter<number>;
  64. /** Event emitted before the centering of the tab begins. */
  65. readonly _beforeCentering: EventEmitter<boolean>;
  66. /** Event emitted before the centering of the tab begins. */
  67. readonly _afterLeavingCenter: EventEmitter<boolean>;
  68. /** Event emitted when the tab completes its animation towards the center. */
  69. readonly _onCentered: EventEmitter<void>;
  70. /** The portal host inside of this container into which the tab body content will be loaded. */
  71. _portalHost: PortalHostDirective;
  72. /** The tab body content to display. */
  73. _content: TemplatePortal;
  74. /** Position that will be used when the tab is immediately becoming visible after creation. */
  75. origin: number;
  76. /** Duration for the tab's animation. */
  77. animationDuration: string;
  78. /** The shifted index position of the tab body, where zero represents the active center tab. */
  79. position: number;
  80. constructor(_elementRef: ElementRef<HTMLElement>, _dir: Directionality, changeDetectorRef: ChangeDetectorRef);
  81. /**
  82. * After initialized, check if the content is centered and has an origin. If so, set the
  83. * special position states that transition the tab from the left or right before centering.
  84. */
  85. ngOnInit(): void;
  86. ngOnDestroy(): void;
  87. _onTranslateTabStarted(event: AnimationEvent): void;
  88. /** The text direction of the containing app. */
  89. _getLayoutDirection(): Direction;
  90. /** Whether the provided position state is considered center, regardless of origin. */
  91. _isCenterPosition(position: MatTabBodyPositionState | string): boolean;
  92. /** Computes the position state that will be used for the tab-body animation trigger. */
  93. private _computePositionAnimationState;
  94. /**
  95. * Computes the position state based on the specified origin position. This is used if the
  96. * tab is becoming visible immediately after creation.
  97. */
  98. private _computePositionFromOrigin;
  99. }