@zarlex/ngx-accessor
Version:
This library provides an adapter to interact with Angular forms. It also provides an adapter to work with object signals and forms
35 lines (34 loc) • 1.74 kB
TypeScript
import { InjectionToken, InputSignal, ModelSignal, Type } from '@angular/core';
import { AbstractControl, ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms';
import { ValidatorError } from './errors';
import * as i0 from "@angular/core";
export declare function inputProviders(cls: Type<AbstractInput<any>>): ({
provide: InjectionToken<readonly ControlValueAccessor[]>;
useExisting: Type<any>;
multi: true;
} | {
provide: InjectionToken<readonly (Validator)[]>;
useExisting: Type<any>;
multi: true;
})[];
export declare abstract class AbstractInput<TValue> implements ControlValueAccessor, Validator {
required: InputSignal<boolean>;
disabled: ModelSignal<boolean>;
private onChange;
private onTouch;
private validator;
private currentValue;
setDisabledState(isDisabled: boolean): void;
registerOnChange(fn: any): void;
registerOnTouched(fn: any): void;
writeValue(value: TValue): void;
registerOnValidatorChange(fn: () => void): void;
validate(control: AbstractControl): ValidationErrors | null;
runValidation(): void;
updateValue(value: TValue): void;
protected abstract setValue(value: TValue): void;
protected abstract validateValue(): Array<ValidatorError>;
protected abstract valueHasChanged(currentValue: TValue, newValue: TValue): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<AbstractInput<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractInput<any>, never, never, { "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "disabled": "disabledChange"; }, never, never, true, never>;
}