| 109 | imports: [MatRipple, _MatInternalFormField], |
| 110 | }) |
| 111 | export class MatCheckbox |
| 112 | implements OnInit, AfterViewInit, OnChanges, ControlValueAccessor, Validator, FocusableOption |
| 113 | { |
| 114 | _elementRef = inject<ElementRef<HTMLElement>>(ElementRef); |
| 115 | private _changeDetectorRef = inject(ChangeDetectorRef); |
| 116 | private _ngZone = inject(NgZone); |
| 117 | protected _animationsDisabled = _animationsDisabled(); |
| 118 | private _options = inject<MatCheckboxDefaultOptions>(MAT_CHECKBOX_DEFAULT_OPTIONS, { |
| 119 | optional: true, |
| 120 | }); |
| 121 | private readonly _injector = inject(Injector); |
| 122 | private _signalFormField: FormField<unknown> | null = null; |
| 123 | |
| 124 | /** Focuses the checkbox. */ |
| 125 | focus() { |
| 126 | this._inputElement.nativeElement.focus(); |
| 127 | } |
| 128 | |
| 129 | /** Creates the change event that will be emitted by the checkbox. */ |
| 130 | protected _createChangeEvent(isChecked: boolean) { |
| 131 | const event = new MatCheckboxChange(); |
| 132 | event.source = this; |
| 133 | event.checked = isChecked; |
| 134 | return event; |
| 135 | } |
| 136 | |
| 137 | /** Gets the element on which to add the animation CSS classes. */ |
| 138 | protected _getAnimationTargetElement() { |
| 139 | return this._inputElement?.nativeElement; |
| 140 | } |
| 141 | |
| 142 | /** CSS classes to add when transitioning between the different checkbox states. */ |
| 143 | protected _animationClasses = { |
| 144 | uncheckedToChecked: 'mdc-checkbox--anim-unchecked-checked', |
| 145 | uncheckedToIndeterminate: 'mdc-checkbox--anim-unchecked-indeterminate', |
| 146 | checkedToUnchecked: 'mdc-checkbox--anim-checked-unchecked', |
| 147 | checkedToIndeterminate: 'mdc-checkbox--anim-checked-indeterminate', |
| 148 | indeterminateToChecked: 'mdc-checkbox--anim-indeterminate-checked', |
| 149 | indeterminateToUnchecked: 'mdc-checkbox--anim-indeterminate-unchecked', |
| 150 | }; |
| 151 | |
| 152 | /** |
| 153 | * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will |
| 154 | * take precedence so this may be omitted. |
| 155 | */ |
| 156 | @Input('aria-label') ariaLabel: string = ''; |
| 157 | |
| 158 | /** |
| 159 | * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element |
| 160 | */ |
| 161 | @Input('aria-labelledby') ariaLabelledby: string | null = null; |
| 162 | |
| 163 | /** The 'aria-describedby' attribute is read after the element's label and field type. */ |
| 164 | @Input('aria-describedby') ariaDescribedby!: string; |
| 165 | |
| 166 | /** |
| 167 | * Users can specify the `aria-expanded` attribute which will be forwarded to the input element |
| 168 | */ |
nothing calls this directly
no test coverage detected