Skip to content

Commit fcbde09

Browse files
committed
refactor(cdk/text-field): convert to standalone
Converts `cdk/text-field` to standalone.
1 parent 3b6ca5c commit fcbde09

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

src/cdk/text-field/autofill.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe('AutofillMonitor', () => {
2222

2323
beforeEach(() => {
2424
TestBed.configureTestingModule({
25-
imports: [TextFieldModule],
26-
declarations: [Inputs],
25+
imports: [TextFieldModule, Inputs],
2726
}).compileComponents();
2827
});
2928

@@ -191,8 +190,7 @@ describe('cdkAutofill', () => {
191190

192191
beforeEach(() => {
193192
TestBed.configureTestingModule({
194-
imports: [TextFieldModule],
195-
declarations: [InputWithCdkAutofilled],
193+
imports: [TextFieldModule, InputWithCdkAutofilled],
196194
}).compileComponents();
197195
});
198196

@@ -222,6 +220,8 @@ describe('cdkAutofill', () => {
222220
<input #input2>
223221
<input #input3>
224222
`,
223+
standalone: true,
224+
imports: [TextFieldModule],
225225
})
226226
class Inputs {
227227
// Cast to `any` so we can stub out some methods in the tests.
@@ -232,6 +232,8 @@ class Inputs {
232232

233233
@Component({
234234
template: `<input #input cdkAutofill>`,
235+
standalone: true,
236+
imports: [TextFieldModule],
235237
})
236238
class InputWithCdkAutofilled {
237239
// Cast to `any` so we can stub out some methods in the tests.

src/cdk/text-field/autofill.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ const listenerOptions = normalizePassiveListenerOptions({passive: true});
4646
export class AutofillMonitor implements OnDestroy {
4747
private _monitoredElements = new Map<Element, MonitoredElementInfo>();
4848

49-
constructor(private _platform: Platform, private _ngZone: NgZone) {}
49+
constructor(
50+
private _platform: Platform,
51+
private _ngZone: NgZone,
52+
) {}
5053

5154
/**
5255
* Monitor for changes in the autofill state of the given input element.
@@ -143,6 +146,7 @@ export class AutofillMonitor implements OnDestroy {
143146
/** A directive that can be used to monitor the autofill state of an input. */
144147
@Directive({
145148
selector: '[cdkAutofill]',
149+
standalone: true,
146150
})
147151
export class CdkAutofill implements OnDestroy, OnInit {
148152
/** Emits when the autofill state of the element changes. */

src/cdk/text-field/autosize.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ describe('CdkTextareaAutosize', () => {
2121

2222
beforeEach(waitForAsync(() => {
2323
TestBed.configureTestingModule({
24-
imports: [FormsModule, TextFieldModule, NoopAnimationsModule],
25-
declarations: [
24+
imports: [
25+
FormsModule,
26+
TextFieldModule,
27+
NoopAnimationsModule,
2628
AutosizeTextAreaWithContent,
2729
AutosizeTextAreaWithValue,
2830
AutosizeTextareaWithNgModel,
@@ -393,6 +395,8 @@ const textareaStyleReset = `
393395
<textarea cdkTextareaAutosize [cdkAutosizeMinRows]="minRows" [cdkAutosizeMaxRows]="maxRows"
394396
#autosize="cdkTextareaAutosize" [placeholder]="placeholder">{{content}}</textarea>`,
395397
styles: [textareaStyleReset],
398+
standalone: true,
399+
imports: [FormsModule, TextFieldModule],
396400
})
397401
class AutosizeTextAreaWithContent {
398402
@ViewChild('autosize') autosize: CdkTextareaAutosize;
@@ -405,6 +409,8 @@ class AutosizeTextAreaWithContent {
405409
@Component({
406410
template: `<textarea cdkTextareaAutosize [value]="value"></textarea>`,
407411
styles: [textareaStyleReset],
412+
standalone: true,
413+
imports: [FormsModule, TextFieldModule],
408414
})
409415
class AutosizeTextAreaWithValue {
410416
value: string = '';
@@ -413,6 +419,8 @@ class AutosizeTextAreaWithValue {
413419
@Component({
414420
template: `<textarea cdkTextareaAutosize [(ngModel)]="model"></textarea>`,
415421
styles: [textareaStyleReset],
422+
standalone: true,
423+
imports: [FormsModule, TextFieldModule],
416424
})
417425
class AutosizeTextareaWithNgModel {
418426
model = '';
@@ -421,6 +429,8 @@ class AutosizeTextareaWithNgModel {
421429
@Component({
422430
template: `<textarea [cdkTextareaAutosize]="false">{{content}}</textarea>`,
423431
styles: [textareaStyleReset],
432+
standalone: true,
433+
imports: [FormsModule, TextFieldModule],
424434
})
425435
class AutosizeTextareaWithoutAutosize {
426436
content: string = '';

src/cdk/text-field/autosize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {DOCUMENT} from '@angular/common';
3535
'rows': '1',
3636
'(input)': '_noopInputHandler()',
3737
},
38+
standalone: true,
3839
})
3940
export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
4041
/** Keep track of the previous textarea value to avoid resizing when the value hasn't changed. */

src/cdk/text-field/text-field-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {CdkAutofill} from './autofill';
1111
import {CdkTextareaAutosize} from './autosize';
1212

1313
@NgModule({
14-
declarations: [CdkAutofill, CdkTextareaAutosize],
14+
imports: [CdkAutofill, CdkTextareaAutosize],
1515
exports: [CdkAutofill, CdkTextareaAutosize],
1616
})
1717
export class TextFieldModule {}

tools/public_api_guard/cdk/text-field.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class CdkAutofill implements OnDestroy, OnInit {
4646
// (undocumented)
4747
ngOnInit(): void;
4848
// (undocumented)
49-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAutofill, "[cdkAutofill]", never, {}, { "cdkAutofill": "cdkAutofill"; }, never, never, false, never>;
49+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAutofill, "[cdkAutofill]", never, {}, { "cdkAutofill": "cdkAutofill"; }, never, never, true, never>;
5050
// (undocumented)
5151
static ɵfac: i0.ɵɵFactoryDeclaration<CdkAutofill, never>;
5252
}
@@ -80,7 +80,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
8080
_setMaxHeight(): void;
8181
_setMinHeight(): void;
8282
// (undocumented)
83-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTextareaAutosize, "textarea[cdkTextareaAutosize]", ["cdkTextareaAutosize"], { "minRows": { "alias": "cdkAutosizeMinRows"; "required": false; }; "maxRows": { "alias": "cdkAutosizeMaxRows"; "required": false; }; "enabled": { "alias": "cdkTextareaAutosize"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; }, {}, never, never, false, never>;
83+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTextareaAutosize, "textarea[cdkTextareaAutosize]", ["cdkTextareaAutosize"], { "minRows": { "alias": "cdkAutosizeMinRows"; "required": false; }; "maxRows": { "alias": "cdkAutosizeMaxRows"; "required": false; }; "enabled": { "alias": "cdkTextareaAutosize"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; }, {}, never, never, true, never>;
8484
// (undocumented)
8585
static ɵfac: i0.ɵɵFactoryDeclaration<CdkTextareaAutosize, [null, null, null, { optional: true; }]>;
8686
}
@@ -92,7 +92,7 @@ export class TextFieldModule {
9292
// (undocumented)
9393
static ɵinj: i0.ɵɵInjectorDeclaration<TextFieldModule>;
9494
// (undocumented)
95-
static ɵmod: i0.ɵɵNgModuleDeclaration<TextFieldModule, [typeof i1.CdkAutofill, typeof i2.CdkTextareaAutosize], never, [typeof i1.CdkAutofill, typeof i2.CdkTextareaAutosize]>;
95+
static ɵmod: i0.ɵɵNgModuleDeclaration<TextFieldModule, never, [typeof i1.CdkAutofill, typeof i2.CdkTextareaAutosize], [typeof i1.CdkAutofill, typeof i2.CdkTextareaAutosize]>;
9696
}
9797

9898
// (No @packageDocumentation comment for this package)

0 commit comments

Comments
 (0)