|
9 | 9 | import {AbstractControl, FormGroupDirective, NgControl, NgForm} from '@angular/forms';
|
10 | 10 | import {Subject} from 'rxjs';
|
11 | 11 | import {ErrorStateMatcher as _ErrorStateMatcher} from '../error/error-options';
|
12 |
| -import {AbstractConstructor, Constructor} from './constructor'; |
13 | 12 |
|
14 | 13 | // Declare ErrorStateMatcher as an interface to have compatibility with Closure Compiler.
|
15 | 14 | interface ErrorStateMatcher extends _ErrorStateMatcher {}
|
16 | 15 |
|
17 |
| -/** |
18 |
| - * @docs-private |
19 |
| - * @deprecated Will be removed together with `mixinErrorState`. |
20 |
| - * @breaking-change 19.0.0 |
21 |
| - */ |
22 |
| -export interface CanUpdateErrorState { |
23 |
| - /** Updates the error state based on the provided error state matcher. */ |
24 |
| - updateErrorState(): void; |
25 |
| - /** Whether the component is in an error state. */ |
26 |
| - errorState: boolean; |
27 |
| - /** An object used to control the error state of the component. */ |
28 |
| - errorStateMatcher: ErrorStateMatcher; |
29 |
| -} |
30 |
| - |
31 |
| -type CanUpdateErrorStateCtor = Constructor<CanUpdateErrorState> & |
32 |
| - AbstractConstructor<CanUpdateErrorState>; |
33 |
| - |
34 |
| -/** @docs-private */ |
35 |
| -interface HasErrorState { |
36 |
| - _parentFormGroup: FormGroupDirective | null; |
37 |
| - _parentForm: NgForm | null; |
38 |
| - _defaultErrorStateMatcher: ErrorStateMatcher; |
39 |
| - |
40 |
| - // These properties are defined as per the `MatFormFieldControl` interface. Since |
41 |
| - // this mixin is commonly used with custom form-field controls, we respect the |
42 |
| - // properties (also with the public name they need according to `MatFormFieldControl`). |
43 |
| - ngControl: NgControl | null; |
44 |
| - stateChanges: Subject<void>; |
45 |
| -} |
46 |
| - |
47 | 16 | /**
|
48 | 17 | * Class that tracks the error state of a component.
|
49 | 18 | * @docs-private
|
@@ -77,59 +46,3 @@ export class _ErrorStateTracker {
|
77 | 46 | }
|
78 | 47 | }
|
79 | 48 | }
|
80 |
| - |
81 |
| -/** |
82 |
| - * Mixin to augment a directive with updateErrorState method. |
83 |
| - * For component with `errorState` and need to update `errorState`. |
84 |
| - * @deprecated Implement the `updateErrorState` method directly. |
85 |
| - * @breaking-change 19.0.0 |
86 |
| - */ |
87 |
| -export function mixinErrorState<T extends AbstractConstructor<HasErrorState>>( |
88 |
| - base: T, |
89 |
| -): CanUpdateErrorStateCtor & T; |
90 |
| -export function mixinErrorState<T extends Constructor<HasErrorState>>( |
91 |
| - base: T, |
92 |
| -): CanUpdateErrorStateCtor & T { |
93 |
| - return class extends base { |
94 |
| - private _tracker: _ErrorStateTracker | undefined; |
95 |
| - |
96 |
| - /** Whether the component is in an error state. */ |
97 |
| - get errorState() { |
98 |
| - return this._getTracker().errorState; |
99 |
| - } |
100 |
| - set errorState(value: boolean) { |
101 |
| - this._getTracker().errorState = value; |
102 |
| - } |
103 |
| - |
104 |
| - /** An object used to control the error state of the component. */ |
105 |
| - get errorStateMatcher() { |
106 |
| - return this._getTracker().matcher; |
107 |
| - } |
108 |
| - set errorStateMatcher(value: ErrorStateMatcher) { |
109 |
| - this._getTracker().matcher = value; |
110 |
| - } |
111 |
| - |
112 |
| - /** Updates the error state based on the provided error state matcher. */ |
113 |
| - updateErrorState() { |
114 |
| - this._getTracker().updateErrorState(); |
115 |
| - } |
116 |
| - |
117 |
| - private _getTracker() { |
118 |
| - if (!this._tracker) { |
119 |
| - this._tracker = new _ErrorStateTracker( |
120 |
| - this._defaultErrorStateMatcher, |
121 |
| - this.ngControl, |
122 |
| - this._parentFormGroup, |
123 |
| - this._parentForm, |
124 |
| - this.stateChanges, |
125 |
| - ); |
126 |
| - } |
127 |
| - |
128 |
| - return this._tracker; |
129 |
| - } |
130 |
| - |
131 |
| - constructor(...args: any[]) { |
132 |
| - super(...args); |
133 |
| - } |
134 |
| - }; |
135 |
| -} |
0 commit comments