Skip to content

Commit 173a682

Browse files
crisbetojosephperrott
authored andcommitted
refactor(stepper): remove dependency on @angular/forms (#15134)
While looking at #15085, I noticed that the only place in the CDK where we use `@angular/forms` is to type an optional input in the stepper. These changes replace the typing with a partial representation of the `AbstractControl` so that we can drop the dependency.
1 parent 824aad2 commit 173a682

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/cdk/stepper/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ ng_module(
99
deps = [
1010
"@angular//packages/common",
1111
"@angular//packages/core",
12-
"@angular//packages/forms",
1312
"@rxjs",
1413
"@rxjs//operators",
1514
"//src/cdk/a11y",

src/cdk/stepper/stepper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
InjectionToken,
3535
} from '@angular/core';
3636
import {DOCUMENT} from '@angular/common';
37-
import {AbstractControl} from '@angular/forms';
3837
import {CdkStepLabel} from './step-label';
3938
import {Observable, Subject, of as obaservableOf} from 'rxjs';
4039
import {startWith, takeUntil} from 'rxjs/operators';
@@ -125,7 +124,12 @@ export class CdkStep implements OnChanges {
125124
@ViewChild(TemplateRef) content: TemplateRef<any>;
126125

127126
/** The top level abstract control of the step. */
128-
@Input() stepControl: AbstractControl;
127+
@Input() stepControl: {
128+
valid: boolean;
129+
invalid: boolean;
130+
pending: boolean;
131+
reset: () => void;
132+
};
129133

130134
/** Whether user has seen the expanded step content or not. */
131135
interacted = false;

tools/public_api_guard/cdk/stepper.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ export declare class CdkStep implements OnChanges {
1212
label: string;
1313
optional: boolean;
1414
state: StepState;
15-
stepControl: AbstractControl;
15+
stepControl: {
16+
valid: boolean;
17+
invalid: boolean;
18+
pending: boolean;
19+
reset: () => void;
20+
};
1621
stepLabel: CdkStepLabel;
1722
constructor(_stepper: CdkStepper, stepperOptions?: StepperOptions);
1823
ngOnChanges(): void;

0 commit comments

Comments
 (0)