11import type { Signal , ElementRef , AfterViewInit } from '@angular/core' ;
22import { Component , contentChildren , signal , computed , ChangeDetectionStrategy , input , viewChildren , output } from '@angular/core' ;
33import { TabComponent } from './tab.component' ;
4- import type { Primitive } from 'tableau-ui-angular/types' ;
54
65@Component ( {
76 selector : 'tab-group' ,
@@ -11,7 +10,7 @@ import type { Primitive } from 'tableau-ui-angular/types';
1110 changeDetection : ChangeDetectionStrategy . OnPush ,
1211 host : { } ,
1312} )
14- export class TabGroupComponent < TKey extends Primitive > implements AfterViewInit {
13+ export class TabGroupComponent implements AfterViewInit {
1514 /**
1615 * Padding for the tab header, can be adjusted to fit design requirements.
1716 * @default '0.25rem 1.5rem'
@@ -35,7 +34,7 @@ export class TabGroupComponent<TKey extends Primitive> implements AfterViewInit
3534 alias : 'autoSelectFirstTab' ,
3635 } ) ;
3736
38- protected readonly $tabs = contentChildren < TabComponent < TKey > > ( TabComponent ) ;
37+ protected readonly $tabs = contentChildren < TabComponent > ( TabComponent ) ;
3938 protected readonly $tabElements = viewChildren < ElementRef < HTMLDivElement > > ( 'tab' ) ;
4039 // Signals to manage the selected index
4140 private readonly $_selectedIndex = signal ( - 1 ) ;
@@ -44,9 +43,9 @@ export class TabGroupComponent<TKey extends Primitive> implements AfterViewInit
4443 return this . $_selectedIndex ;
4544 }
4645 // nullable Signal type needs to be set explicitly -> ng-packagr strips nullability
47- readonly $selectedTab : Signal < TabComponent < TKey > | null > = computed ( ( ) => this . $tabs ( ) [ this . $selectedIndex ( ) ] ?? null ) ;
46+ readonly $selectedTab : Signal < TabComponent | null > = computed ( ( ) => this . $tabs ( ) [ this . $selectedIndex ( ) ] ?? null ) ;
4847
49- readonly tabSelected = output < { index : number ; key : TKey | undefined ; tab : TabComponent < TKey > } > ( ) ;
48+ readonly tabSelected = output < { index : number ; key : string | undefined ; tab : TabComponent } > ( ) ;
5049 selectTabByIndex ( index : number ) {
5150 const tabs = this . $tabs ( ) ;
5251
@@ -62,7 +61,7 @@ export class TabGroupComponent<TKey extends Primitive> implements AfterViewInit
6261 tab . afterActivate . emit ( ) ;
6362 } ) ;
6463 }
65- selectTabByKey ( key : TKey ) {
64+ selectTabByKey ( key : string ) {
6665 const tabs = this . $tabs ( ) ;
6766 const index = tabs . findIndex ( ( tab ) => tab . $key ( ) === key ) ;
6867 if ( index !== - 1 ) {
0 commit comments