import { TemplatePortal } from '@angular/cdk/portal' ; import { ChangeDetectionStrategy , Component , ContentChild , Inject , InjectionToken , Input , OnChanges , OnDestroy , OnInit , SimpleChanges , TemplateRef , ViewChild , ViewContainerRef , ViewEncapsulation , } from '@angular/core' ; import { CanDisable , mixinDisabled } from '@sbb-esta/angular/core' ; import { Subject } from 'rxjs' ; import { SBB_TAB_CONTENT } from './tab-content' ; import { SbbTabLabel , SBB_TAB_LABEL } from './tab-label' ; const _SbbTabMixinBase = mixinDisabled ( class { } ) ; docs-private export const SBB_TAB_GROUP = new InjectionToken < any > ( 'SBB_TAB_GROUP' ) ; @ Component ( { selector : 'sbb-tab' , templateUrl : 'tab.html' , inputs : [ 'disabled' ] , changeDetection : ChangeDetectionStrategy . Default , encapsulation : ViewEncapsulation . None , exportAs : 'sbbTab' , } ) export class SbbTab extends _SbbTabMixinBase implements OnInit , CanDisable , OnChanges , OnDestroy { /** Content for the tab label given by `<ng-template sbb-tab-label>`. */ @ ContentChild ( SBB_TAB_LABEL ) get templateLabel ( ) : SbbTabLabel { return this . _templateLabel ; } set templateLabel ( value ) { this . _setTemplateLabelInput ( value ) ; } protected _templateLabel : SbbTabLabel ; /**
     * Template provided in the tab content that will be used if present, used to enable lazy-loading
     */ @ ContentChild ( SBB_TAB_CONTENT , { read : TemplateRef , static : true } ) _explicitContent : TemplateRef < any > ; /** Template inside the SbbTab view that contains an `<ng-content>`. */ @ ViewChild ( TemplateRef , { static : true } ) _implicitContent : TemplateRef < any > ; /** Plain text label for the tab, used when there is no template label. */ @ Input ( 'label' ) textLabel : string = '' ; /** Aria label for the tab. */ @ Input ( 'aria-label' ) ariaLabel : string ; /**
     * Reference to the element that the tab is labelled by.
     * Will be cleared if `aria-label` is set at the same time.
     */ @ Input ( 'aria-labelledby' ) ariaLabelledby : string ; /** Portal that will be the hosted content of the tab */ private _contentPortal : TemplatePortal | null = null ; docs-private get content ( ) : TemplatePortal | null { return this . _contentPortal ; } /** Emits whenever the internal state of the tab changes. */ readonly _stateChanges = new Subject < void > ( ) ; /**
     * The relatively indexed position where 0 represents the center, negative is left, and positive
     * represents the right.
     */ position : number | null = null ; /**
     * The initial relatively index origin of the tab if it was created and selected after there
     * was already a selected tab. Provides context of what position the tab should originate from.
     */ origin : number | null = null ; /**
     * Whether the tab is currently active.
     */ isActive : boolean = false ; constructor ( private _viewContainerRef , @ Inject ( SBB_TAB_GROUP ) public _closestTabGroup ) { super ( ) ; } ngOnChanges ( changes ) { if ( changes . hasOwnProperty ( 'textLabel' ) || changes . hasOwnProperty ( 'disabled' ) ) { this . _stateChanges . next ( ) ; } } ngOnDestroy ( ) { this . _stateChanges . complete ( ) ; } ngOnInit ( ) { this . _contentPortal = new TemplatePortal ( this . _explicitContent || this . _implicitContent , this . _viewContainerRef ) ; } docs-private protected _setTemplateLabelInput ( value ) { if ( value ) { this . _templateLabel = value ; } } }