Skip to content

Commit f306cc1

Browse files
committed
refactor(material/input): convert to standalone
Converts `material/input` to standalone.
1 parent ac17a9c commit f306cc1

File tree

7 files changed

+40
-11
lines changed

7 files changed

+40
-11
lines changed

src/material/input/input.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {dispatchFakeEvent, wrappedErrorMessage} from '../../cdk/testing/private';
1+
import {dispatchFakeEvent, wrappedErrorMessage} from '@angular/cdk/testing/private';
22
import {
33
ChangeDetectionStrategy,
44
Component,

src/material/input/input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ let nextUniqueId = 0;
7777
'(input)': '_onInput()',
7878
},
7979
providers: [{provide: MatFormFieldControl, useExisting: MatInput}],
80+
standalone: true,
8081
})
8182
export class MatInput
8283
implements MatFormFieldControl<any>, OnChanges, OnDestroy, AfterViewInit, DoCheck

src/material/input/module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {MatFormFieldModule} from '@angular/material/form-field';
1313
import {MatInput} from './input';
1414

1515
@NgModule({
16-
imports: [MatCommonModule, MatFormFieldModule],
16+
imports: [MatCommonModule, MatFormFieldModule, MatInput],
1717
exports: [MatInput, MatFormFieldModule, TextFieldModule, MatCommonModule],
18-
declarations: [MatInput],
1918
})
2019
export class MatInputModule {}

src/material/input/public-api.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ export {MatInput} from './input';
1010
export {MatInputModule} from './module';
1111
export * from './input-value-accessor';
1212
export * from './input-errors';
13+
14+
// Re-provide these for convenience since they used to be provided implicitly.
15+
export {
16+
MatFormField,
17+
MatLabel,
18+
MatHint,
19+
MatError,
20+
MatPrefix,
21+
MatSuffix,
22+
} from '@angular/material/form-field';

src/material/input/testing/input-harness.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ describe('MatInputHarness', () => {
1414

1515
beforeEach(async () => {
1616
await TestBed.configureTestingModule({
17-
imports: [NoopAnimationsModule, MatInputModule, FormsModule],
18-
declarations: [InputHarnessTest],
17+
imports: [NoopAnimationsModule, MatInputModule, FormsModule, InputHarnessTest],
1918
}).compileComponents();
2019

2120
fixture = TestBed.createComponent(InputHarnessTest);
@@ -266,6 +265,8 @@ describe('MatInputHarness', () => {
266265
<input matNativeControl placeholder="Color control" id="colorControl" type="color">
267266
</mat-form-field>
268267
`,
268+
standalone: true,
269+
imports: [MatInputModule, FormsModule],
269270
})
270271
class InputHarnessTest {
271272
inputType = 'number';

src/material/input/testing/native-select-harness.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ describe('MatNativeSelectHarness', () => {
1313

1414
beforeEach(async () => {
1515
await TestBed.configureTestingModule({
16-
imports: [NoopAnimationsModule, MatInputModule, FormsModule],
17-
declarations: [SelectHarnessTest],
16+
imports: [NoopAnimationsModule, MatInputModule, FormsModule, SelectHarnessTest],
1817
}).compileComponents();
1918

2019
fixture = TestBed.createComponent(SelectHarnessTest);
@@ -220,6 +219,8 @@ describe('MatNativeSelectHarness', () => {
220219
</select>
221220
</mat-form-field>
222221
`,
222+
standalone: true,
223+
imports: [MatInputModule, FormsModule],
223224
})
224225
class SelectHarnessTest {
225226
favoriteFood: string;

tools/public_api_guard/material/input.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ import { ElementRef } from '@angular/core';
1212
import { ErrorStateMatcher } from '@angular/material/core';
1313
import { FormGroupDirective } from '@angular/forms';
1414
import * as i0 from '@angular/core';
15-
import * as i2 from '@angular/material/core';
16-
import * as i3 from '@angular/material/form-field';
15+
import * as i1 from '@angular/material/core';
16+
import * as i2 from '@angular/material/form-field';
1717
import * as i4 from '@angular/cdk/text-field';
1818
import { InjectionToken } from '@angular/core';
19+
import { MatError } from '@angular/material/form-field';
1920
import { MatFormField } from '@angular/material/form-field';
2021
import { MatFormFieldControl } from '@angular/material/form-field';
22+
import { MatHint } from '@angular/material/form-field';
23+
import { MatLabel } from '@angular/material/form-field';
24+
import { MatPrefix } from '@angular/material/form-field';
25+
import { MatSuffix } from '@angular/material/form-field';
2126
import { NgControl } from '@angular/forms';
2227
import { NgForm } from '@angular/forms';
2328
import { NgZone } from '@angular/core';
@@ -34,6 +39,12 @@ export const MAT_INPUT_VALUE_ACCESSOR: InjectionToken<{
3439
value: any;
3540
}>;
3641

42+
export { MatError }
43+
44+
export { MatFormField }
45+
46+
export { MatHint }
47+
3748
// @public (undocumented)
3849
export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy, AfterViewInit, DoCheck {
3950
constructor(_elementRef: ElementRef<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>, _platform: Platform, ngControl: NgControl, parentForm: NgForm, parentFormGroup: FormGroupDirective, defaultErrorStateMatcher: ErrorStateMatcher, inputValueAccessor: any, _autofillMonitor: AutofillMonitor, ngZone: NgZone, _formField?: MatFormField | undefined);
@@ -110,7 +121,7 @@ export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy,
110121
get value(): string;
111122
set value(value: any);
112123
// (undocumented)
113-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatInput, "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", ["matInput"], { "disabled": { "alias": "disabled"; "required": false; }; "id": { "alias": "id"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "name": { "alias": "name"; "required": false; }; "required": { "alias": "required"; "required": false; }; "type": { "alias": "type"; "required": false; }; "errorStateMatcher": { "alias": "errorStateMatcher"; "required": false; }; "userAriaDescribedBy": { "alias": "aria-describedby"; "required": false; }; "value": { "alias": "value"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; }, {}, never, never, false, never>;
124+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatInput, "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", ["matInput"], { "disabled": { "alias": "disabled"; "required": false; }; "id": { "alias": "id"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "name": { "alias": "name"; "required": false; }; "required": { "alias": "required"; "required": false; }; "type": { "alias": "type"; "required": false; }; "errorStateMatcher": { "alias": "errorStateMatcher"; "required": false; }; "userAriaDescribedBy": { "alias": "aria-describedby"; "required": false; }; "value": { "alias": "value"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; }, {}, never, never, true, never>;
114125
// (undocumented)
115126
static ɵfac: i0.ɵɵFactoryDeclaration<MatInput, [null, null, { optional: true; self: true; }, { optional: true; }, { optional: true; }, null, { optional: true; self: true; }, null, null, { optional: true; }]>;
116127
}
@@ -122,9 +133,15 @@ export class MatInputModule {
122133
// (undocumented)
123134
static ɵinj: i0.ɵɵInjectorDeclaration<MatInputModule>;
124135
// (undocumented)
125-
static ɵmod: i0.ɵɵNgModuleDeclaration<MatInputModule, [typeof i1.MatInput], [typeof i2.MatCommonModule, typeof i3.MatFormFieldModule], [typeof i1.MatInput, typeof i3.MatFormFieldModule, typeof i4.TextFieldModule, typeof i2.MatCommonModule]>;
136+
static ɵmod: i0.ɵɵNgModuleDeclaration<MatInputModule, never, [typeof i1.MatCommonModule, typeof i2.MatFormFieldModule, typeof i3.MatInput], [typeof i3.MatInput, typeof i2.MatFormFieldModule, typeof i4.TextFieldModule, typeof i1.MatCommonModule]>;
126137
}
127138

139+
export { MatLabel }
140+
141+
export { MatPrefix }
142+
143+
export { MatSuffix }
144+
128145
// (No @packageDocumentation comment for this package)
129146

130147
```

0 commit comments

Comments
 (0)