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