| 115 | ], |
| 116 | }) |
| 117 | export class FormField<T> { |
| 118 | /** |
| 119 | * The field to bind to the underlying form control. |
| 120 | */ |
| 121 | readonly field = input.required<Field<T>>({alias: 'formField'}); |
| 122 | |
| 123 | /** |
| 124 | * `FieldState` for the currently bound field. |
| 125 | */ |
| 126 | readonly state = computed<FieldState<T>>(() => this.field()()); |
| 127 | |
| 128 | /** @internal */ |
| 129 | readonly renderer = inject(Renderer2); |
| 130 | |
| 131 | /** @internal */ |
| 132 | readonly destroyRef = inject(DestroyRef); |
| 133 | |
| 134 | /** |
| 135 | * The node injector for the DOM element hosting this field binding. |
| 136 | */ |
| 137 | readonly injector = inject(Injector); |
| 138 | |
| 139 | /** |
| 140 | * The DOM element hosting this field binding. |
| 141 | */ |
| 142 | readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement; |
| 143 | |
| 144 | // Compute some helper booleans about the type of element we're sitting on. |
| 145 | private readonly elementIsNativeFormElement = isNativeFormElement(this.element); |
| 146 | private readonly elementAcceptsTextualValues = isTextualFormElement(this.element); |
| 147 | private _elementAcceptsMinMax: boolean | undefined; |
| 148 | |
| 149 | /** |
| 150 | * Utility that casts `this.element` to `NativeFormControl` to avoid repeated type guards. Only |
| 151 | * safe to access when `elementIsNativeFormElement` is true. |
| 152 | * |
| 153 | * @internal |
| 154 | */ |
| 155 | readonly nativeFormElement: NativeFormControl = (this.elementIsNativeFormElement |
| 156 | ? this.element |
| 157 | : undefined) as NativeFormControl; |
| 158 | |
| 159 | /** |
| 160 | * Current focus implementation, set by `registerAsBinding`. |
| 161 | */ |
| 162 | private focuser = (options?: FocusOptions) => this.element.focus(options); |
| 163 | |
| 164 | /** Any `ControlValueAccessor` instances provided on the host element. */ |
| 165 | private readonly controlValueAccessors = inject(NG_VALUE_ACCESSOR, {optional: true, self: true}); |
| 166 | |
| 167 | private readonly config = inject(SIGNAL_FORMS_CONFIG, {optional: true}); |
| 168 | private readonly validityMonitor = inject(InputValidityMonitor); |
| 169 | |
| 170 | /** @internal */ |
| 171 | readonly parseErrorsSource = signal< |
| 172 | Signal<readonly ValidationError.WithoutFieldTree[]> | undefined |
| 173 | >(undefined); |
| 174 |
nothing calls this directly
no test coverage detected