import { ControlValueAccessor } from '@angular/forms'; import * as i0 from '@angular/core'; import { EventEmitter, ProviderToken, Provider } from '@angular/core'; import { SubjectLike, Subscribable, Subject } from 'rxjs'; /** * A host component of a custom Angular form control. * * It exposes several RxJS streams for value, change, disabled, and touched events. * * @see `SimpleComponentValueAccessorHost` for a generic implementation of this * interface that simplifies the process for most use cases. * * @see `ComponentValueAccessor` for adapting this host into a standard * Angular `ControlValueAccessor`. */ declare abstract class ComponentValueAccessorHost { /** * A stream of value changes from input binding. */ abstract readonly valueInput$: SubjectLike; /** * A stream of value changes from DOM events. */ abstract readonly valueChange$: Subscribable; /** * A stream of disabled state changes from input binding. */ abstract readonly disabled$: SubjectLike; /** * A stream of touched events from DOM events. */ abstract readonly touched$: Subscribable; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵprov: i0.ɵɵInjectableDeclaration>; } /** * A simple implementation of `ComponentValueAccessorHost` that suits most * use cases of creating custom Angular form control components. * * It defines the following input/output bindings: * - `value/valueChange`: A two-way binding for `valueInput$/valueChange$`. * - `disabled`: An input binding for `disabled$`. * - `touched`: An output binding for `touched$`. * * It also defines the following signals for convenience: * - `value`: A signal that emits the current value of the form control. * - `disabled`: A signal that emits the current disabled state of the form control. */ declare class SimpleComponentValueAccessorHost implements ComponentValueAccessorHost { set valueInput(v: T); readonly valueInput$: Subject; readonly valueChange$: EventEmitter; set disabledInput(v: boolean); readonly disabled$: Subject; readonly touched$: EventEmitter; /** * A signal that emits the current value of the form control. */ readonly value: i0.Signal; /** * A signal that emits the current disabled state of the form control. */ readonly disabled: i0.Signal; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, never, never, { "valueInput": { "alias": "value"; "required": false; }; "disabledInput": { "alias": "disabled"; "required": false; }; }, { "valueChange$": "valueChange"; "touched$": "touched"; }, never, never, true, never>; } /** * An adapter that adapts a `ComponentValueAccessorHost` into a `ControlValueAccessor`. * It uses the `ComponentValueAccessorHost` provided at the `self` level to implement * the `ControlValueAccessor` interface. */ declare class ComponentValueAccessor implements ControlValueAccessor { protected readonly host: ComponentValueAccessorHost; writeValue(value: unknown): void; registerOnChange(fn: (value: unknown) => void): void; registerOnTouched(fn: () => void): void; setDisabledState(disabled: boolean): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Provides the essential providers for a custom Angular form control component * that implements `ComponentValueAccessorHost` * * @param host The provider token to the `ComponentValueAccessorHost` component * * @example * ```ts * \@Component({ * providers: [provideComponentValueAccessor(MyFormControlComponent)], * }) * class MyFormControlComponent implements ComponentValueAccessorHost { * // ... * } * ``` */ declare function provideComponentValueAccessor(host: ProviderToken): Provider[]; export { ComponentValueAccessor, ComponentValueAccessorHost, SimpleComponentValueAccessorHost, provideComponentValueAccessor };