MCPcopy Create free account
hub / github.com/angular/components / MatFormField

Class MatFormField

src/material/form-field/form-field.ts:189–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 ],
188})
189export class MatFormField
190 implements FloatingLabelParent, AfterContentInit, AfterContentChecked, AfterViewInit, OnDestroy
191{
192 _elementRef = inject(ElementRef);
193 private _changeDetectorRef = inject(ChangeDetectorRef);
194 private _platform = inject(Platform);
195 private _idGenerator = inject(_IdGenerator);
196 private _ngZone = inject(NgZone);
197 private _defaults = inject<MatFormFieldDefaultOptions>(MAT_FORM_FIELD_DEFAULT_OPTIONS, {
198 optional: true,
199 });
200 private _currentDirection!: Direction;
201
202 protected _unwrapMaybeSignal<T>(value: T | Signal<T>) {
203 return isSignal(value) ? value() : value;
204 }
205
206 @ViewChild('textField') _textField!: ElementRef<HTMLElement>;
207 @ViewChild('iconPrefixContainer') _iconPrefixContainer!: ElementRef<HTMLElement>;
208 @ViewChild('textPrefixContainer') _textPrefixContainer!: ElementRef<HTMLElement>;
209 @ViewChild('iconSuffixContainer') _iconSuffixContainer!: ElementRef<HTMLElement>;
210 @ViewChild('textSuffixContainer') _textSuffixContainer!: ElementRef<HTMLElement>;
211 @ViewChild(MatFormFieldFloatingLabel) _floatingLabel: MatFormFieldFloatingLabel | undefined;
212 @ViewChild(MatFormFieldNotchedOutline) _notchedOutline: MatFormFieldNotchedOutline | undefined;
213 @ViewChild(MatFormFieldLineRipple) _lineRipple: MatFormFieldLineRipple | undefined;
214
215 private _iconPrefixContainerSignal = viewChild<ElementRef<HTMLElement>>('iconPrefixContainer');
216 private _textPrefixContainerSignal = viewChild<ElementRef<HTMLElement>>('textPrefixContainer');
217 private _iconSuffixContainerSignal = viewChild<ElementRef<HTMLElement>>('iconSuffixContainer');
218 private _textSuffixContainerSignal = viewChild<ElementRef<HTMLElement>>('textSuffixContainer');
219 private _prefixSuffixContainers = computed(() => {
220 return [
221 this._iconPrefixContainerSignal(),
222 this._textPrefixContainerSignal(),
223 this._iconSuffixContainerSignal(),
224 this._textSuffixContainerSignal(),
225 ]
226 .map(container => container?.nativeElement)
227 .filter(e => e !== undefined);
228 });
229
230 @ContentChild(_MatFormFieldControl) _formFieldControl!: MatFormFieldControl<any>;
231 @ContentChildren(MAT_PREFIX, {descendants: true}) _prefixChildren!: QueryList<MatPrefix>;
232 @ContentChildren(MAT_SUFFIX, {descendants: true}) _suffixChildren!: QueryList<MatSuffix>;
233 @ContentChildren(MAT_ERROR, {descendants: true}) _errorChildren!: QueryList<MatError>;
234 @ContentChildren(MatHint, {descendants: true}) _hintChildren!: QueryList<MatHint>;
235
236 private readonly _labelChild = contentChild(MatLabel);
237
238 /** Whether the required marker should be hidden. */
239 @Input()
240 get hideRequiredMarker(): boolean {
241 return this._hideRequiredMarker;
242 }
243 set hideRequiredMarker(value: BooleanInput) {
244 this._hideRequiredMarker = coerceBooleanProperty(value);
245 }
246 private _hideRequiredMarker = false;

Callers

nothing calls this directly

Calls 6

_animationsDisabledFunction · 0.90
computedFunction · 0.85
signalFunction · 0.85
_hasFloatingLabelMethod · 0.80
filterMethod · 0.45
getIdMethod · 0.45

Tested by

no test coverage detected