1
- import { booleanAttribute , computed , Directive , effect , input } from '@angular/core' ;
1
+ import { booleanAttribute , computed , Directive , effect , input , numberAttribute } from '@angular/core' ;
2
+ import { BooleanInput } from '../coreui.types' ;
2
3
3
4
@Directive ( {
4
5
selector : '[cNavLink]' ,
@@ -12,6 +13,8 @@ import { booleanAttribute, computed, Directive, effect, input } from '@angular/c
12
13
}
13
14
} )
14
15
export class NavLinkDirective {
16
+ static ngAcceptInputType_disabled : BooleanInput ;
17
+
15
18
/**
16
19
* Sets .nav-link class to the host. [docs]
17
20
* @default true
@@ -30,20 +33,25 @@ export class NavLinkDirective {
30
33
*/
31
34
readonly disabled = input ( false , { transform : booleanAttribute } ) ;
32
35
36
+ /**
37
+ * The tabindex attribute specifies the tab order of an element (when the "tab" button is used for navigating).
38
+ */
39
+ readonly tabindex = input ( undefined , { transform : numberAttribute } ) ;
40
+
33
41
readonly ariaCurrent = computed ( ( ) => {
34
42
return this . active ( ) ? 'page' : null ;
35
43
} ) ;
36
44
37
45
ariaDisabled : boolean | null = null ;
38
46
attrDisabled : boolean | string | null = null ;
39
- attrTabindex : '-1' | null = null ;
47
+ attrTabindex : number | null = null ;
40
48
styleCursor : 'pointer' | null = null ;
41
49
42
50
readonly #disabledEffect = effect ( ( ) => {
43
51
const disabled = this . disabled ( ) ;
44
52
this . ariaDisabled = disabled || null ;
45
53
this . attrDisabled = disabled ? '' : null ;
46
- this . attrTabindex = disabled ? '-1' : null ;
54
+ this . attrTabindex = disabled ? - 1 : ( this . tabindex ( ) ?? null ) ;
47
55
this . styleCursor = disabled ? null : 'pointer' ;
48
56
} ) ;
49
57
0 commit comments