Skip to content

fix(stepper): avoid breaking change in stepControl type #15464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 55 additions & 6 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ export class CdkStep implements OnChanges {
@ViewChild(TemplateRef) content: TemplateRef<any>;

/** The top level abstract control of the step. */
@Input() stepControl: {
valid: boolean;
invalid: boolean;
pending: boolean;
reset: () => void;
};
@Input() stepControl: FormControlLike;

/** Whether user has seen the expanded step content or not. */
interacted = false;
Expand Down Expand Up @@ -516,3 +511,57 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
return stepperElement === focusedElement || stepperElement.contains(focusedElement);
}
}


/**
* Simplified representation of a FormControl from @angular/forms.
* Used to avoid having to bring in @angular/forms for a single optional interface.
* @docs-private
*/
interface FormControlLike {
asyncValidator: () => any | null;
dirty: boolean;
disabled: boolean;
enabled: boolean;
errors: {[key: string]: any} | null;
invalid: boolean;
parent: any;
pending: boolean;
pristine: boolean;
root: FormControlLike;
status: string;
statusChanges: Observable<any>;
touched: boolean;
untouched: boolean;
updateOn: any;
valid: boolean;
validator: () => any | null;
value: any;
valueChanges: Observable<any>;
clearAsyncValidators(): void;
clearValidators(): void;
disable(opts?: any): void;
enable(opts?: any): void;
get(path: (string | number)[] | string): FormControlLike | 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: () => any | (() => any)[] | null): void;
setErrors(errors: {[key: string]: any} | null, opts?: any): void;
setParent(parent: any): void;
setValidators(newValidator: () => any | (() => any)[] | null): void;
setValue(value: any, options?: Object): void;
updateValueAndValidity(opts?: any): void;
patchValue(value: any, options?: any): void;
registerOnChange(fn: Function): void;
registerOnDisabledChange(fn: (isDisabled: boolean) => void): void;
reset(formState?: any, options?: any): void;
setValue(value: any, options?: any): void;
}
7 changes: 1 addition & 6 deletions tools/public_api_guard/cdk/stepper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ export declare class CdkStep implements OnChanges {
label: string;
optional: boolean;
state: StepState;
stepControl: {
valid: boolean;
invalid: boolean;
pending: boolean;
reset: () => void;
};
stepControl: FormControlLike;
stepLabel: CdkStepLabel;
constructor(_stepper: CdkStepper, stepperOptions?: StepperOptions);
ngOnChanges(): void;
Expand Down