-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
Copy pathform-field-control.ts
92 lines (72 loc) · 2.86 KB
/
form-field-control.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Observable} from 'rxjs';
import {AbstractControlDirective, NgControl} from '@angular/forms';
import {Directive} from '@angular/core';
/** An interface which allows a control to work inside of a `MatFormField`. */
@Directive()
export abstract class MatFormFieldControl<T> {
/** The value of the control. */
value: T | null;
/**
* Stream that emits whenever the state of the control changes such that the parent `MatFormField`
* needs to run change detection.
*/
readonly stateChanges: Observable<void>;
/** The element ID for this control. */
readonly id: string;
/** The placeholder for this control. */
readonly placeholder: string;
/** Gets the AbstractControlDirective for this control. */
readonly ngControl: NgControl | AbstractControlDirective | null;
/** Whether the control is focused. */
readonly focused: boolean;
/** Whether the control is empty. */
readonly empty: boolean;
/** Whether the `MatFormField` label should try to float. */
readonly shouldLabelFloat: boolean;
/** Whether the control is required. */
readonly required: boolean;
/** Whether the control is disabled. */
readonly disabled: boolean;
/** Whether the control is in an error state. */
readonly errorState: boolean;
/**
* An optional name for the control type that can be used to distinguish `mat-form-field` elements
* based on their control type. The form field will add a class,
* `mat-form-field-type-{{controlType}}` to its root element.
*/
readonly controlType?: string;
/**
* Whether the input is currently in an autofilled state. If property is not present on the
* control it is assumed to be false.
*/
readonly autofilled?: boolean;
/**
* Value of `aria-describedby` that should be merged with the described-by ids
* which are set by the form-field.
*/
readonly userAriaDescribedBy?: string;
/**
* Value of `aria-labelledby` that should be merged with the labelled-by ids
* which are set by the form-field.
*/
readonly userAriaLabelledBy?: string;
/**
* Whether to automatically assign the ID of the form field as the `for` attribute
* on the `<label>` inside the form field. Set this to true to prevent the form
* field from associating the label with non-native elements.
*/
readonly disableAutomaticLabeling?: boolean;
/** Sets the list of element IDs that currently describe this control. */
abstract setDescribedByIds(ids: string[]): void;
/** Sets the list of element IDs that currently label this control. */
abstract setLabelledByIds(ids: string[]): void;
/** Handles a click on the control's container. */
abstract onContainerClick(event: MouseEvent): void;
}