Skip to content

Commit

Permalink
fix(cdk/stepper): remove mock of forms type
Browse files Browse the repository at this point in the history
Previously we were mocking out the `AbstractControl` type, because we didn't want to bring in additional code for the optional forms integration. That's no longer necessary, because we can use type-only imports.

(cherry picked from commit 9eb1f86)
  • Loading branch information
crisbeto committed Oct 4, 2024
1 parent 104b593 commit fa43a24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 54 deletions.
54 changes: 2 additions & 52 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
booleanAttribute,
numberAttribute,
} from '@angular/core';
import {type AbstractControl} from '@angular/forms';
import {_getFocusedElementPierceShadowDom} from '@angular/cdk/platform';
import {Observable, of as observableOf, Subject} from 'rxjs';
import {startWith, takeUntil} from 'rxjs/operators';
Expand Down Expand Up @@ -118,7 +119,7 @@ export class CdkStep implements OnChanges {
@ViewChild(TemplateRef, {static: true}) content: TemplateRef<any>;

/** The top level abstract control of the step. */
@Input() stepControl: AbstractControlLike;
@Input() stepControl: AbstractControl;

/** Whether user has attempted to move away from the step. */
interacted = false;
Expand Down Expand Up @@ -558,54 +559,3 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
return index > -1 && (!this.steps || index < this.steps.length);
}
}

/**
* Simplified representation of an "AbstractControl" from @angular/forms.
* Used to avoid having to bring in @angular/forms for a single optional interface.
* @docs-private
*/
interface AbstractControlLike {
asyncValidator: ((control: any) => any) | null;
dirty: boolean;
disabled: boolean;
enabled: boolean;
errors: {[key: string]: any} | null;
invalid: boolean;
parent: any;
pending: boolean;
pristine: boolean;
root: AbstractControlLike;
status: string;
readonly statusChanges: Observable<any>;
touched: boolean;
untouched: boolean;
updateOn: any;
valid: boolean;
validator: ((control: any) => any) | null;
value: any;
readonly valueChanges: Observable<any>;
clearAsyncValidators(): void;
clearValidators(): void;
disable(opts?: any): void;
enable(opts?: any): void;
get(path: (string | number)[] | string): AbstractControlLike | null;
getError(errorCode: string, path?: (string | number)[] | string): any;
hasError(errorCode: string, path?: (string | number)[] | string): boolean;
markAllAsTouched(): void;
markAsDirty(opts?: any): void;
markAsPending(opts?: any): void;
markAsPristine(opts?: any): void;
markAsTouched(opts?: any): void;
markAsUntouched(opts?: any): void;
patchValue(value: any, options?: Object): void;
reset(value?: any, options?: Object): void;
setAsyncValidators(newValidator: (control: any) => any | ((control: any) => any)[] | null): void;
setErrors(errors: {[key: string]: any} | null, opts?: any): void;
setParent(parent: any): void;
setValidators(newValidator: (control: any) => any | ((control: any) => any)[] | null): void;
setValue(value: any, options?: Object): void;
updateValueAndValidity(opts?: any): void;
patchValue(value: any, options?: any): void;
reset(formState?: any, options?: any): void;
setValue(value: any, options?: any): void;
}
4 changes: 2 additions & 2 deletions tools/public_api_guard/cdk/stepper.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
```ts

import { AbstractControl } from '@angular/forms';
import { AfterContentInit } from '@angular/core';
import { AfterViewInit } from '@angular/core';
import { ChangeDetectorRef } from '@angular/core';
Expand All @@ -14,7 +15,6 @@ import { FocusableOption } from '@angular/cdk/a11y';
import * as i0 from '@angular/core';
import * as i1 from '@angular/cdk/bidi';
import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs';
import { OnChanges } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { QueryList } from '@angular/core';
Expand Down Expand Up @@ -57,7 +57,7 @@ export class CdkStep implements OnChanges {
select(): void;
_showError(): boolean;
state: StepState;
stepControl: AbstractControlLike;
stepControl: AbstractControl;
stepLabel: CdkStepLabel;
// (undocumented)
_stepper: CdkStepper;
Expand Down

0 comments on commit fa43a24

Please sign in to comment.