88 ElementRef ,
99 inject ,
1010 Injector ,
11- Input ,
1211 input ,
1312 InputSignal ,
1413 OnInit ,
@@ -43,10 +42,21 @@ export class TabDirective implements FocusableOption, OnInit {
4342
4443 /**
4544 * Disabled attribute
46- * @type boolean
45+ * @return boolean
4746 * @default false
4847 */
49- @Input ( { transform : booleanAttribute } )
48+ readonly disabledInput = input ( false , { transform : booleanAttribute , alias : 'disabled' } ) ;
49+
50+ readonly #disabled = signal ( false ) ;
51+ readonly attrDisabled = computed ( ( ) => this . #disabled( ) || null ) ;
52+
53+ readonly #disabledEffect = effect ( ( ) => {
54+ const disabled = this . disabledInput ( ) ;
55+ untracked ( ( ) => {
56+ this . disabled = disabled ;
57+ } ) ;
58+ } ) ;
59+
5060 set disabled ( value : boolean ) {
5161 this . #disabled. set ( value ) ;
5262 }
@@ -55,9 +65,6 @@ export class TabDirective implements FocusableOption, OnInit {
5565 return this . #disabled( ) ;
5666 }
5767
58- readonly #disabled = signal ( false ) ;
59- readonly attrDisabled = computed ( ( ) => this . #disabled( ) || null ) ;
60-
6168 /**
6269 * Item key.
6370 * @type string | number
@@ -95,18 +102,19 @@ export class TabDirective implements FocusableOption, OnInit {
95102 ( ) => this . ariaControls ( ) ?? `${ this . #tabsService. id ( ) } -panel-${ this . itemKey ( ) } `
96103 ) ;
97104
98- disabledEffect = effect ( ( ) => {
99- if ( ! this . #disabled( ) ) {
105+ readonly #disabledSignalEffect = effect ( ( ) => {
106+ const disabled = this . #disabled( ) ;
107+ if ( ! disabled ) {
100108 const click$ = fromEvent < MouseEvent > ( this . #elementRef. nativeElement , 'click' ) ;
101109 const focusIn$ = fromEvent < FocusEvent > ( this . #elementRef. nativeElement , 'focusin' ) ;
102110
103111 merge ( focusIn$ , click$ )
104112 . pipe (
105- filter ( ( $event ) => ! this . # disabled( ) ) ,
113+ filter ( ( $event ) => ! disabled ) ,
106114 tap ( ( $event ) => {
107115 this . #tabsService. activeItemKey . set ( untracked ( this . itemKey ) ) ;
108116 } ) ,
109- takeWhile ( ( ) => ! this . # disabled( ) ) ,
117+ takeWhile ( ( ) => ! disabled ) ,
110118 takeUntilDestroyed ( this . #destroyRef)
111119 )
112120 . subscribe ( ) ;
0 commit comments