8
8
ElementRef ,
9
9
inject ,
10
10
Injector ,
11
- Input ,
12
11
input ,
13
12
InputSignal ,
14
13
OnInit ,
@@ -43,10 +42,21 @@ export class TabDirective implements FocusableOption, OnInit {
43
42
44
43
/**
45
44
* Disabled attribute
46
- * @type boolean
45
+ * @return boolean
47
46
* @default false
48
47
*/
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
+
50
60
set disabled ( value : boolean ) {
51
61
this . #disabled. set ( value ) ;
52
62
}
@@ -55,9 +65,6 @@ export class TabDirective implements FocusableOption, OnInit {
55
65
return this . #disabled( ) ;
56
66
}
57
67
58
- readonly #disabled = signal ( false ) ;
59
- readonly attrDisabled = computed ( ( ) => this . #disabled( ) || null ) ;
60
-
61
68
/**
62
69
* Item key.
63
70
* @type string | number
@@ -95,18 +102,19 @@ export class TabDirective implements FocusableOption, OnInit {
95
102
( ) => this . ariaControls ( ) ?? `${ this . #tabsService. id ( ) } -panel-${ this . itemKey ( ) } `
96
103
) ;
97
104
98
- disabledEffect = effect ( ( ) => {
99
- if ( ! this . #disabled( ) ) {
105
+ readonly #disabledSignalEffect = effect ( ( ) => {
106
+ const disabled = this . #disabled( ) ;
107
+ if ( ! disabled ) {
100
108
const click$ = fromEvent < MouseEvent > ( this . #elementRef. nativeElement , 'click' ) ;
101
109
const focusIn$ = fromEvent < FocusEvent > ( this . #elementRef. nativeElement , 'focusin' ) ;
102
110
103
111
merge ( focusIn$ , click$ )
104
112
. pipe (
105
- filter ( ( $event ) => ! this . # disabled( ) ) ,
113
+ filter ( ( $event ) => ! disabled ) ,
106
114
tap ( ( $event ) => {
107
115
this . #tabsService. activeItemKey . set ( untracked ( this . itemKey ) ) ;
108
116
} ) ,
109
- takeWhile ( ( ) => ! this . # disabled( ) ) ,
117
+ takeWhile ( ( ) => ! disabled ) ,
110
118
takeUntilDestroyed ( this . #destroyRef)
111
119
)
112
120
. subscribe ( ) ;
0 commit comments