UNPKG

@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

37 lines (36 loc) 2.47 kB
import { AfterViewInit, ElementRef, InjectionToken, InputSignal, OnDestroy, OutputEmitterRef, WritableSignal } from '@angular/core'; import { AsyncValidator, AsyncValidatorFn, ControlValueAccessor, NgModel, UntypedFormControl, Validator, ValidatorFn } from '@angular/forms'; import { Accessor } from '../accessor/interface'; import * as i0 from "@angular/core"; export interface AccessorHost { accessor: InputSignal<Accessor<any, any>>; required: InputSignal<boolean>; } export declare const ngxAccessorHost: InjectionToken<AccessorHost>; export type AccessorValueType<TAccessor extends Accessor<any, any>> = TAccessor extends Accessor<any, infer TValueType> ? TValueType : any; export declare const ACCESSOR: InjectionToken<AccessorService>; export declare class AccessorService { accessor: WritableSignal<Accessor<any, any>>; static ɵfac: i0.ɵɵFactoryDeclaration<AccessorService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AccessorService>; } export declare class AccessorDirective<TAccessor extends Accessor<any, any>, TValue = AccessorValueType<TAccessor>> extends NgModel implements OnDestroy, AfterViewInit, AccessorHost { valueChange: OutputEmitterRef<TValue>; protected accessorValueChange: OutputEmitterRef<any>; protected element: ElementRef; private subscriptions; accessor: InputSignal<TAccessor>; required: InputSignal<boolean>; readonly control: UntypedFormControl; accessorService: AccessorService; constructor(validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[], valueAccessors: ControlValueAccessor[]); ngAfterViewInit(): void; ngOnDestroy(): void; viewToModelUpdate(newValue: any): void; protected modelToControlUpdate(): void; protected setValidationErrorsOnModel(): void; protected observeModelChanges(): void; protected observeValidationErrors(): void; static ɵfac: i0.ɵɵFactoryDeclaration<AccessorDirective<any, any>, [{ optional: true; self: true; }, { optional: true; self: true; }, { optional: true; self: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration<AccessorDirective<any, any>, "[ngxAccessor]", never, { "accessor": { "alias": "ngxAccessor"; "required": true; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; }, { "valueChange": "ngxAccessorValueChange"; "accessorValueChange": "accessorValueChange"; }, never, never, false, never>; }