1
- import { Directive , ElementRef , HostBinding , Input , Renderer2 } from '@angular/core' ;
2
- import { BooleanInput , coerceBooleanProperty } from '@angular/cdk/coercion' ;
1
+ import { booleanAttribute , Directive , ElementRef , HostBinding , Input , Renderer2 } from '@angular/core' ;
3
2
4
3
@Directive ( {
5
4
selector : 'input[cFormCheckInput]' ,
6
5
standalone : true
7
6
} )
8
7
export class FormCheckInputDirective {
9
8
10
- static ngAcceptInputType_checked : BooleanInput ;
11
- static ngAcceptInputType_indeterminate : BooleanInput ;
12
-
13
9
/**
14
10
* Specifies the type of component.
15
11
* @type {'checkbox' | 'radio' }
@@ -21,10 +17,11 @@ export class FormCheckInputDirective {
21
17
/**
22
18
* Set component indeterminate state.
23
19
* @type boolean
20
+ * @default false
24
21
*/
25
- @Input ( )
22
+ @Input ( { transform : booleanAttribute } )
26
23
set indeterminate ( value : boolean ) {
27
- const indeterminate = coerceBooleanProperty ( value ) ;
24
+ const indeterminate = value ;
28
25
if ( this . _indeterminate !== indeterminate ) {
29
26
this . _indeterminate = indeterminate ;
30
27
const htmlInputElement = this . hostElement . nativeElement as HTMLInputElement ;
@@ -44,6 +41,7 @@ export class FormCheckInputDirective {
44
41
/**
45
42
* Set component validation state to valid.
46
43
* @type boolean
44
+ * @default undefined
47
45
*/
48
46
@Input ( ) valid ?: boolean ;
49
47
@@ -56,9 +54,9 @@ export class FormCheckInputDirective {
56
54
} ;
57
55
}
58
56
59
- @Input ( )
57
+ @Input ( { transform : booleanAttribute } )
60
58
set checked ( value : boolean ) {
61
- const checked = coerceBooleanProperty ( value ) ;
59
+ const checked = value ;
62
60
const htmlInputElement = this . hostElement ?. nativeElement as HTMLInputElement ;
63
61
if ( htmlInputElement ) {
64
62
this . renderer . setProperty ( htmlInputElement , 'checked' , checked ) ;
0 commit comments