Skip to content

refactor(material/stepper): remove deprecated APIs for version 13 #23328

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
Feb 18, 2022
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
6 changes: 6 additions & 0 deletions src/cdk/schematics/ng-update/data/constructor-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export type ConstructorChecksUpgradeData = string;
* automatically through type checking.
*/
export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
[TargetVersion.V13]: [
{
pr: 'https://github.com/angular/components/pull/23328',
changes: ['CdkStepper']
}
],
[TargetVersion.V12]: [
{
pr: 'https://github.com/angular/components/pull/21876',
Expand Down
13 changes: 1 addition & 12 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
NumberInput,
} from '@angular/cdk/coercion';
import {ENTER, hasModifierKey, SPACE} from '@angular/cdk/keycodes';
import {DOCUMENT} from '@angular/common';
import {
AfterViewInit,
ChangeDetectionStrategy,
Expand Down Expand Up @@ -338,22 +337,12 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
this._keyManager.withVerticalOrientation(value === 'vertical');
}
}

/**
* @deprecated To be turned into a private property. Use `orientation` instead.
* @breaking-change 13.0.0
*/
protected _orientation: StepperOrientation = 'horizontal';
private _orientation: StepperOrientation = 'horizontal';

constructor(
@Optional() private _dir: Directionality,
private _changeDetectorRef: ChangeDetectorRef,
private _elementRef: ElementRef<HTMLElement>,
/**
* @deprecated No longer in use, to be removed.
* @breaking-change 13.0.0
*/
@Inject(DOCUMENT) _document: any,
) {
this._groupId = nextId++;
}
Expand Down
4 changes: 4 additions & 0 deletions src/material/schematics/ng-update/data/constructor-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
pr: 'https://github.com/angular/components/pull/23573',
changes: ['MatDatepicker', 'MatDateRangePicker'],
},
{
pr: 'https://github.com/angular/components/pull/23328',
changes: ['MatStepper'],
},
],
[TargetVersion.V12]: [
{
Expand Down
4 changes: 1 addition & 3 deletions src/material/stepper/stepper-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {ErrorStateMatcher, MatCommonModule, MatRippleModule} from '@angular/mate
import {MatIconModule} from '@angular/material/icon';
import {MatStepHeader} from './step-header';
import {MatStepLabel} from './step-label';
import {MatHorizontalStepper, MatStep, MatStepper, MatVerticalStepper} from './stepper';
import {MatStep, MatStepper} from './stepper';
import {MatStepperNext, MatStepperPrevious} from './stepper-button';
import {MatStepperIcon} from './stepper-icon';
import {MAT_STEPPER_INTL_PROVIDER} from './stepper-intl';
Expand Down Expand Up @@ -43,8 +43,6 @@ import {MatStepContent} from './step-content';
MatStepContent,
],
declarations: [
MatHorizontalStepper,
MatVerticalStepper,
MatStep,
MatStepLabel,
MatStepper,
Expand Down
18 changes: 1 addition & 17 deletions src/material/stepper/stepper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {_supportsShadowDom} from '@angular/cdk/platform';
import {merge, Observable, Subject} from 'rxjs';
import {map, take} from 'rxjs/operators';
import {MatStepHeader, MatStepperModule} from './index';
import {MatHorizontalStepper, MatStep, MatStepper, MatVerticalStepper} from './stepper';
import {MatStep, MatStepper} from './stepper';
import {MatStepperNext, MatStepperPrevious} from './stepper-button';
import {MatStepperIntl} from './stepper-intl';
import {MatFormFieldModule} from '@angular/material/form-field';
Expand Down Expand Up @@ -979,13 +979,6 @@ describe('MatStepper', () => {
});

describe('vertical stepper', () => {
it('should be able to use the legacy classes in queries', () => {
const fixture = createComponent(SimpleMatVerticalStepperApp);
fixture.detectChanges();

expect(fixture.componentInstance.legacyTokenStepper).toBeTruthy();
});

it('should set the aria-orientation to "vertical"', () => {
const fixture = createComponent(SimpleMatVerticalStepperApp);
fixture.detectChanges();
Expand Down Expand Up @@ -1090,13 +1083,6 @@ describe('MatStepper', () => {
});

describe('horizontal stepper', () => {
it('should be able to use the legacy classes in queries', () => {
const fixture = createComponent(SimpleMatHorizontalStepperApp);
fixture.detectChanges();

expect(fixture.componentInstance.legacyTokenStepper).toBeTruthy();
});

it('should set the aria-orientation to "horizontal"', () => {
const fixture = createComponent(SimpleMatHorizontalStepperApp);
fixture.detectChanges();
Expand Down Expand Up @@ -1857,7 +1843,6 @@ class MatHorizontalStepperWithErrorsApp implements OnInit {
`,
})
class SimpleMatHorizontalStepperApp {
@ViewChild(MatHorizontalStepper) legacyTokenStepper: MatHorizontalStepper;
inputLabel = 'Step 3';
disableRipple = false;
stepperTheme: ThemePalette;
Expand Down Expand Up @@ -1894,7 +1879,6 @@ class SimpleMatHorizontalStepperApp {
`,
})
class SimpleMatVerticalStepperApp {
@ViewChild(MatVerticalStepper) legacyTokenStepper: MatVerticalStepper;
inputLabel = 'Step 3';
showStepTwo = true;
disableRipple = false;
Expand Down
41 changes: 2 additions & 39 deletions src/material/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
Component,
ContentChild,
ContentChildren,
Directive,
ElementRef,
EventEmitter,
forwardRef,
Expand All @@ -39,7 +38,6 @@ import {
ViewEncapsulation,
} from '@angular/core';
import {FormControl, FormGroupDirective, NgForm} from '@angular/forms';
import {DOCUMENT} from '@angular/common';
import {ErrorStateMatcher, ThemePalette} from '@angular/material/core';
import {TemplatePortal} from '@angular/cdk/portal';
import {Subject, Subscription} from 'rxjs';
Expand Down Expand Up @@ -120,36 +118,6 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI
}
}

/**
* Proxies the public APIs from `MatStepper` to the deprecated `MatHorizontalStepper` and
* `MatVerticalStepper`.
* @deprecated Use `MatStepper` instead.
* @breaking-change 13.0.0
* @docs-private
*/
@Directive()
abstract class _MatProxyStepperBase extends CdkStepper {
override readonly steps: QueryList<MatStep>;
readonly animationDone: EventEmitter<void>;
disableRipple: boolean;
color: ThemePalette;
labelPosition: 'bottom' | 'end';
}

/**
* @deprecated Use `MatStepper` instead.
* @breaking-change 13.0.0
*/
@Directive({selector: 'mat-horizontal-stepper'})
export class MatHorizontalStepper extends _MatProxyStepperBase {}

/**
* @deprecated Use `MatStepper` instead.
* @breaking-change 13.0.0
*/
@Directive({selector: 'mat-vertical-stepper'})
export class MatVerticalStepper extends _MatProxyStepperBase {}

@Component({
selector: 'mat-stepper, mat-vertical-stepper, mat-horizontal-stepper, [matStepper]',
exportAs: 'matStepper, matVerticalStepper, matHorizontalStepper',
Expand All @@ -170,11 +138,7 @@ export class MatVerticalStepper extends _MatProxyStepperBase {}
matStepperAnimations.horizontalStepTransition,
matStepperAnimations.verticalStepTransition,
],
providers: [
{provide: CdkStepper, useExisting: MatStepper},
{provide: MatHorizontalStepper, useExisting: MatStepper},
{provide: MatVerticalStepper, useExisting: MatStepper},
],
providers: [{provide: CdkStepper, useExisting: MatStepper}],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down Expand Up @@ -217,9 +181,8 @@ export class MatStepper extends CdkStepper implements AfterContentInit {
@Optional() dir: Directionality,
changeDetectorRef: ChangeDetectorRef,
elementRef: ElementRef<HTMLElement>,
@Inject(DOCUMENT) _document: any,
) {
super(dir, changeDetectorRef, elementRef, _document);
super(dir, changeDetectorRef, elementRef);
const nodeName = elementRef.nativeElement.nodeName.toLowerCase();
this.orientation = nodeName === 'mat-vertical-stepper' ? 'vertical' : 'horizontal';
}
Expand Down
7 changes: 2 additions & 5 deletions tools/public_api_guard/cdk/stepper.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export class CdkStepLabel {

// @public (undocumented)
export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
constructor(_dir: Directionality, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>,
_document: any);
constructor(_dir: Directionality, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>);
protected readonly _destroyed: Subject<void>;
_getAnimationDirection(index: number): StepContentPositionState;
_getFocusIndex(): number | null;
Expand All @@ -110,8 +109,6 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
_onKeydown(event: KeyboardEvent): void;
get orientation(): StepperOrientation;
set orientation(value: StepperOrientation);
// @deprecated (undocumented)
protected _orientation: StepperOrientation;
previous(): void;
reset(): void;
get selected(): CdkStep | undefined;
Expand All @@ -126,7 +123,7 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkStepper, "[cdkStepper]", ["cdkStepper"], { "linear": "linear"; "selectedIndex": "selectedIndex"; "selected": "selected"; "orientation": "orientation"; }, { "selectionChange": "selectionChange"; }, ["_steps", "_stepHeader"]>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepper, [{ optional: true; }, null, null, null]>;
static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepper, [{ optional: true; }, null, null]>;
}

// @public (undocumented)
Expand Down
22 changes: 3 additions & 19 deletions tools/public_api_guard/material/stepper.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ export const MAT_STEPPER_INTL_PROVIDER: {
// @public
export function MAT_STEPPER_INTL_PROVIDER_FACTORY(parentIntl: MatStepperIntl): MatStepperIntl;

// @public @deprecated (undocumented)
export class MatHorizontalStepper extends _MatProxyStepperBase {
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatHorizontalStepper, "mat-horizontal-stepper", never, {}, {}, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatHorizontalStepper, never>;
}

// @public (undocumented)
export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentInit, OnDestroy {
constructor(stepper: MatStepper, _errorStateMatcher: ErrorStateMatcher, _viewContainerRef: ViewContainerRef, stepperOptions?: StepperOptions);
Expand Down Expand Up @@ -135,7 +127,7 @@ export class MatStepLabel extends CdkStepLabel {

// @public (undocumented)
export class MatStepper extends CdkStepper implements AfterContentInit {
constructor(dir: Directionality, changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef<HTMLElement>, _document: any);
constructor(dir: Directionality, changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef<HTMLElement>);
readonly animationDone: EventEmitter<void>;
readonly _animationDone: Subject<AnimationEvent_2>;
color: ThemePalette;
Expand All @@ -153,7 +145,7 @@ export class MatStepper extends CdkStepper implements AfterContentInit {
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatStepper, "mat-stepper, mat-vertical-stepper, mat-horizontal-stepper, [matStepper]", ["matStepper", "matVerticalStepper", "matHorizontalStepper"], { "selectedIndex": "selectedIndex"; "disableRipple": "disableRipple"; "color": "color"; "labelPosition": "labelPosition"; }, { "animationDone": "animationDone"; }, ["_steps", "_icons"], never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepper, [{ optional: true; }, null, null, null]>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepper, [{ optional: true; }, null, null]>;
}

// @public
Expand Down Expand Up @@ -200,7 +192,7 @@ export class MatStepperModule {
// (undocumented)
static ɵinj: i0.ɵɵInjectorDeclaration<MatStepperModule>;
// (undocumented)
static ɵmod: i0.ɵɵNgModuleDeclaration<MatStepperModule, [typeof i1.MatHorizontalStepper, typeof i1.MatVerticalStepper, typeof i1.MatStep, typeof i2.MatStepLabel, typeof i1.MatStepper, typeof i3.MatStepperNext, typeof i3.MatStepperPrevious, typeof i4.MatStepHeader, typeof i5.MatStepperIcon, typeof i6.MatStepContent], [typeof i7.MatCommonModule, typeof i8.CommonModule, typeof i9.PortalModule, typeof i10.MatButtonModule, typeof i11.CdkStepperModule, typeof i12.MatIconModule, typeof i7.MatRippleModule], [typeof i7.MatCommonModule, typeof i1.MatStep, typeof i2.MatStepLabel, typeof i1.MatStepper, typeof i3.MatStepperNext, typeof i3.MatStepperPrevious, typeof i4.MatStepHeader, typeof i5.MatStepperIcon, typeof i6.MatStepContent]>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MatStepperModule, [typeof i1.MatStep, typeof i2.MatStepLabel, typeof i1.MatStepper, typeof i3.MatStepperNext, typeof i3.MatStepperPrevious, typeof i4.MatStepHeader, typeof i5.MatStepperIcon, typeof i6.MatStepContent], [typeof i7.MatCommonModule, typeof i8.CommonModule, typeof i9.PortalModule, typeof i10.MatButtonModule, typeof i11.CdkStepperModule, typeof i12.MatIconModule, typeof i7.MatRippleModule], [typeof i7.MatCommonModule, typeof i1.MatStep, typeof i2.MatStepLabel, typeof i1.MatStepper, typeof i3.MatStepperNext, typeof i3.MatStepperPrevious, typeof i4.MatStepHeader, typeof i5.MatStepperIcon, typeof i6.MatStepContent]>;
}

// @public
Expand All @@ -219,14 +211,6 @@ export class MatStepperPrevious extends CdkStepperPrevious {
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepperPrevious, never>;
}

// @public @deprecated (undocumented)
export class MatVerticalStepper extends _MatProxyStepperBase {
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatVerticalStepper, "mat-vertical-stepper", never, {}, {}, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatVerticalStepper, never>;
}

export { StepperOrientation }

export { StepState }
Expand Down