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' ;
32
43@Directive ( {
54 selector : 'input[cFormCheckInput]' ,
65 standalone : true
76} )
87export class FormCheckInputDirective {
98
10- static ngAcceptInputType_checked : BooleanInput ;
11- static ngAcceptInputType_indeterminate : BooleanInput ;
12-
139 /**
1410 * Specifies the type of component.
1511 * @type {'checkbox' | 'radio' }
@@ -21,10 +17,11 @@ export class FormCheckInputDirective {
2117 /**
2218 * Set component indeterminate state.
2319 * @type boolean
20+ * @default false
2421 */
25- @Input ( )
22+ @Input ( { transform : booleanAttribute } )
2623 set indeterminate ( value : boolean ) {
27- const indeterminate = coerceBooleanProperty ( value ) ;
24+ const indeterminate = value ;
2825 if ( this . _indeterminate !== indeterminate ) {
2926 this . _indeterminate = indeterminate ;
3027 const htmlInputElement = this . hostElement . nativeElement as HTMLInputElement ;
@@ -44,6 +41,7 @@ export class FormCheckInputDirective {
4441 /**
4542 * Set component validation state to valid.
4643 * @type boolean
44+ * @default undefined
4745 */
4846 @Input ( ) valid ?: boolean ;
4947
@@ -56,9 +54,9 @@ export class FormCheckInputDirective {
5654 } ;
5755 }
5856
59- @Input ( )
57+ @Input ( { transform : booleanAttribute } )
6058 set checked ( value : boolean ) {
61- const checked = coerceBooleanProperty ( value ) ;
59+ const checked = value ;
6260 const htmlInputElement = this . hostElement ?. nativeElement as HTMLInputElement ;
6361 if ( htmlInputElement ) {
6462 this . renderer . setProperty ( htmlInputElement , 'checked' , checked ) ;
0 commit comments