import { Directive } from '@angular/core'; import { ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms'; @Directive() export abstract class FormFieldComponent implements ControlValueAccessor, Validator { touched = false; disabled = false; protected _value: I | undefined; get value(): I | undefined { return this._value; } // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars onChange = (value?: I) => {}; onTouched = () => {}; markAsTouched() { if (!this.touched) { this.onTouched(); this.touched = true; } } setDisabledState(disabled: boolean) { this.disabled = disabled; } registerOnChange(onChange: (value?: I) => void): void { this.onChange = onChange; } registerOnTouched(onTouched: () => void): void { this.onTouched = onTouched; } writeValue(option: I): void { this._value = option; } validate(): ValidationErrors | null { return null; } }