Skip to content

refactor(material/stepper): remove all usages of deprecated selectors #22838

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
Jun 1, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{!isEditable ? 'Enable edit mode' : 'Disable edit mode'}}
</button>

<mat-horizontal-stepper linear #stepper>
<mat-stepper linear #stepper>
<!-- #docregion editable -->
<mat-step [stepControl]="firstFormGroup" [editable]="isEditable">
<!-- #enddocregion editable -->
Expand Down Expand Up @@ -41,4 +41,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-horizontal-stepper #stepper>
<mat-stepper #stepper>
<mat-step [stepControl]="firstFormGroup" errorMessage="Name is required.">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
Expand Down Expand Up @@ -35,4 +35,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-horizontal-stepper>
<mat-stepper>
<mat-step>
<ng-template matStepLabel>One</ng-template>
<button matStepperNext>Next</button>
Expand All @@ -12,4 +12,4 @@
<ng-template matStepLabel>Three</ng-template>
<button matStepperPrevious>Previous</button>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{optionalLabelTextChoice}}
</mat-radio-button>
</mat-radio-group>
<mat-horizontal-stepper class="demo-stepper" #stepper>
<mat-stepper class="demo-stepper" #stepper>
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
Expand Down Expand Up @@ -56,4 +56,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- #docregion label-position -->
<mat-horizontal-stepper labelPosition="bottom" #stepper>
<mat-stepper labelPosition="bottom" #stepper>
<!-- #enddocregion label-position -->
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
Expand Down Expand Up @@ -37,4 +37,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-vertical-stepper>
<mat-stepper orientation="vertical">
<mat-step>
<ng-template matStepLabel>Step 1</ng-template>
<ng-template matStepContent>
Expand All @@ -19,4 +19,4 @@
<p>This content was rendered eagerly</p>
<button mat-button matStepperPrevious>Back</button>
</mat-step>
</mat-vertical-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{!isOptional ? 'Enable optional steps' : 'Disable optional steps'}}
</button>

<mat-horizontal-stepper linear #stepper>
<mat-stepper linear #stepper>
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
Expand Down Expand Up @@ -39,4 +39,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
</button>
<mat-horizontal-stepper [linear]="isLinear" #stepper>
<mat-stepper [linear]="isLinear" #stepper>
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
Expand Down Expand Up @@ -37,4 +37,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-horizontal-stepper #stepper>
<mat-stepper #stepper>
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
Expand Down Expand Up @@ -33,10 +33,10 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>

<!-- #docregion states -->
<mat-horizontal-stepper>
<mat-stepper>
<!-- #docregion label -->
<mat-step label="Step 1" state="phone">
<p>Put down your phones.</p>
Expand Down Expand Up @@ -64,6 +64,6 @@
<ng-template matStepperIcon="chat">
<mat-icon>forum</mat-icon>
</ng-template>
</mat-horizontal-stepper>
</mat-stepper>
<!-- #enddocregion override-icons -->
<!-- #enddocregion states -->
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
</button>
<mat-vertical-stepper [linear]="isLinear" #stepper>
<mat-stepper orientation="vertical" [linear]="isLinear" #stepper>
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
Expand Down Expand Up @@ -36,4 +36,4 @@
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-vertical-stepper>
</mat-stepper>
20 changes: 10 additions & 10 deletions src/dev-app/stepper/stepper-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h3>Linear Stepper Demo using a single form</h3>
</form>

<h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
<mat-horizontal-stepper #linearHorizontalStepper="matHorizontalStepper" [linear]="!isNonLinear"
<mat-stepper #linearHorizontalStepper="matHorizontalStepper" [linear]="!isNonLinear"
[disableRipple]="disableRipple"
[labelPosition]="showLabelBottom ? 'bottom' : 'end'"
[color]="theme">
Expand Down Expand Up @@ -124,11 +124,11 @@ <h3>Linear Horizontal Stepper Demo using a different form for each step</h3>
</div>
</form>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>

<h3>Vertical Stepper Demo</h3>
<mat-checkbox [(ngModel)]="isNonEditable">Make steps non-editable</mat-checkbox>
<mat-vertical-stepper [color]="theme">
<mat-stepper orientation="vertical" [color]="theme">
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
Expand Down Expand Up @@ -180,10 +180,10 @@ <h3>Vertical Stepper Demo</h3>
<button mat-button>Done</button>
</div>
</mat-step>
</mat-vertical-stepper>
</mat-stepper>

<h3>Horizontal Stepper Demo with Text Label</h3>
<mat-horizontal-stepper [color]="theme">
<mat-stepper [color]="theme">
<mat-step label="Fill out your name">
<mat-form-field>
<mat-label>First name</mat-label>
Expand Down Expand Up @@ -227,10 +227,10 @@ <h3>Horizontal Stepper Demo with Text Label</h3>
<button mat-button>Done</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>

<h3>Horizontal Stepper Demo with Templated Label</h3>
<mat-horizontal-stepper [color]="theme">
<mat-stepper [color]="theme">
<mat-step *ngFor="let step of steps">
<ng-template matStepLabel>{{step.label}}</ng-template>
<mat-form-field>
Expand All @@ -242,15 +242,15 @@ <h3>Horizontal Stepper Demo with Templated Label</h3>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>

<h3>Stepper with autosize textarea</h3>
<mat-horizontal-stepper [color]="theme">
<mat-stepper [color]="theme">
<mat-step label="Step 1">
<mat-form-field>
<mat-label>Autosize textarea</mat-label>
<textarea matInput cdkTextareaAutosize>This is an autosize textarea, it should adjust to the size of its content.</textarea>
</mat-form-field>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>

4 changes: 2 additions & 2 deletions src/material/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2245,15 +2245,15 @@ class AutosizeTextareaInATab {}

@Component({
template: `
<mat-horizontal-stepper>
<mat-stepper>
<mat-step label="Step 1">
<mat-form-field>
<textarea matInput matTextareaAautosize>
Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
</textarea>
</mat-form-field>
</mat-step>
</mat-horizontal-stepper>
</mat-stepper>
`
})
class AutosizeTextareaInAStep {}
Expand Down
2 changes: 1 addition & 1 deletion src/material/stepper/stepper.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('stepper', () => {
beforeEach(async () => await browser.get('/stepper'));

it('should render a stepper', async () => {
await expectToExist('mat-horizontal-stepper');
await expectToExist('mat-stepper');
});

describe('basic behavior', () => {
Expand Down
26 changes: 11 additions & 15 deletions src/material/stepper/stepper.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ that drives a stepped workflow. Material stepper extends the CDK stepper and has
styling.

### Stepper variants
There are two stepper components: `mat-horizontal-stepper` and `mat-vertical-stepper`. They
can be used the same way. The only difference is the orientation of stepper.
There are two stepper variants: `horizontal` and `vertical`. You can switch between the two using
the `orientation` attribute.

<!-- example(stepper-overview) -->

<!-- example(stepper-vertical) -->

`mat-horizontal-stepper` selector can be used to create a horizontal stepper, and
`mat-vertical-stepper` can be used to create a vertical stepper. `mat-step` components need to be
placed inside either one of the two stepper components.

### Labels
If a step's label is only text, then the `label` attribute can be used.
<!-- example({"example": "stepper-overview",
Expand All @@ -29,7 +25,7 @@ For more complex labels, add a template with the `matStepLabel` directive inside
"region": "step-label"}) -->

#### Label position
For `mat-horizontal-stepper` it's possible to define the position of the label. `end` is the
For a horizontal `mat-stepper` it's possible to define the position of the label. `end` is the
default value, while `bottom` will place it under the step icon instead of at its side.
This behaviour is controlled by `labelPosition` property.

Expand All @@ -45,10 +41,10 @@ There are two button directives to support navigation between different steps:
"region": "buttons"}) -->

### Linear stepper
The `linear` attribute can be set on `mat-horizontal-stepper` and `mat-vertical-stepper` to create
a linear stepper that requires the user to complete previous steps before proceeding to following
steps. For each `mat-step`, the `stepControl` attribute can be set to the top level
`AbstractControl` that is used to check the validity of the step.
The `linear` attribute can be set on `mat-stepper` to create a linear stepper that requires the
user to complete previous steps before proceeding to following steps. For each `mat-step`, the
`stepControl` attribute can be set to the top level `AbstractControl` that is used to check the
validity of the step.

There are two possible approaches. One is using a single form for stepper, and the other is
using a different form for each step.
Expand All @@ -64,7 +60,7 @@ are completed.

```html
<form [formGroup]="formGroup">
<mat-horizontal-stepper formArrayName="formArray" linear>
<mat-stepper formArrayName="formArray" linear>
<mat-step formGroupName="0" [stepControl]="formArray.get([0])">
...
<div>
Expand All @@ -79,13 +75,13 @@ are completed.
</div>
</mat-step>
...
</mat-horizontal-stepper>
</mat-stepper>
</form>
```

#### Using a different form for each step
```html
<mat-vertical-stepper linear>
<mat-stepper orientation="vertical" linear>
<mat-step [stepControl]="formGroup1">
<form [formGroup]="formGroup1">
...
Expand All @@ -96,7 +92,7 @@ are completed.
...
</form>
</mat-step>
</mat-vertical-stepper>
</mat-stepper>
```
### Types of steps

Expand Down
Loading