Skip to content

Commit 3c1f4fd

Browse files
committed
Several name changes, etc based on review
1 parent a56e57f commit 3c1f4fd

File tree

7 files changed

+46
-38
lines changed

7 files changed

+46
-38
lines changed

src/cdk/stepper/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import {NgModule} from '@angular/core';
1010
import {CdkStepper, CdkStep} from './stepper';
1111
import {CommonModule} from '@angular/common';
1212
import {CdkStepLabel} from './step-label';
13-
import {PortalModule} from '../portal';
1413

1514
@NgModule({
16-
imports: [CommonModule, PortalModule],
15+
imports: [CommonModule],
1716
exports: [CdkStep, CdkStepper, CdkStepLabel],
1817
declarations: [CdkStep, CdkStepper, CdkStepLabel]
1918
})

src/cdk/stepper/stepper.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
Output,
1414
QueryList,
1515
Directive,
16-
ViewChildren,
1716
// This import is only used to define a generic type. The current TypeScript version incorrectly
1817
// considers such imports as unused (https://github.com/Microsoft/TypeScript/issues/14953)
1918
// tslint:disable-next-line:no-unused-variable
@@ -31,16 +30,16 @@ let nextId = 0;
3130

3231
/** Change event emitted on selection changes. */
3332
export class CdkStepperSelectionEvent {
34-
/** The index of the step that is newly selected during this change event. */
33+
/** Index of the step now selected. */
3534
selectedIndex: number;
3635

37-
/** The index of the step that was previously selected. */
36+
/** Index of the step previously selected. */
3837
previouslySelectedIndex: number;
3938

40-
/** The new step component that is selected ruing this change event. */
39+
/** The step instance now selected. */
4140
selectedStep: CdkStep;
4241

43-
/** The step component that was previously selected. */
42+
/** The step instance previously selected. */
4443
previouslySelectedStep: CdkStep;
4544
}
4645

@@ -70,7 +69,7 @@ export class CdkStep {
7069
@Directive({
7170
selector: 'cdk-stepper',
7271
host: {
73-
'(focus)': '_setStepFocused()',
72+
'(focus)': '_focusStep()',
7473
'(keydown)': '_onKeydown($event)',
7574
},
7675
})
@@ -82,18 +81,19 @@ export class CdkStepper {
8281
_stepHeader: QueryList<ElementRef>;
8382

8483
/** The index of the selected step. */
84+
@Input()
8585
get selectedIndex() { return this._selectedIndex; }
8686
set selectedIndex(index: number) {
8787
if (this._selectedIndex != index) {
8888
this._emitStepperSelectionEvent(index);
89-
this._setStepFocused(this._selectedIndex);
89+
this._focusStep(this._selectedIndex);
9090
}
9191
}
9292
private _selectedIndex: number = 0;
9393

94-
/** Returns the step that is selected. */
94+
/** The step that is selected. */
95+
@Input()
9596
get selected() { return this._steps[this.selectedIndex]; }
96-
/** Sets selectedIndex as the index of the provided step. */
9797
set selected(step: CdkStep) {
9898
let index = this._steps.toArray().indexOf(step);
9999
this.selectedIndex = index;
@@ -146,10 +146,10 @@ export class CdkStepper {
146146
_onKeydown(event: KeyboardEvent) {
147147
switch (event.keyCode) {
148148
case RIGHT_ARROW:
149-
this._setStepFocused((this._focusIndex + 1) % this._steps.length);
149+
this._focusStep((this._focusIndex + 1) % this._steps.length);
150150
break;
151151
case LEFT_ARROW:
152-
this._setStepFocused((this._focusIndex + this._steps.length - 1) % this._steps.length);
152+
this._focusStep((this._focusIndex + this._steps.length - 1) % this._steps.length);
153153
break;
154154
case SPACE:
155155
case ENTER:
@@ -162,7 +162,7 @@ export class CdkStepper {
162162
event.preventDefault();
163163
}
164164

165-
private _setStepFocused(index: number) {
165+
private _focusStep(index: number) {
166166
this._focusIndex = index;
167167
this._stepHeader.toArray()[this._focusIndex].nativeElement.focus();
168168
}

src/lib/stepper/stepper-horizontal.html

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
<div *ngFor="let step of _steps; let i = index; let isLast = last">
2-
<div #stepHeader class="mat-stepper-header" role="tab"
3-
[id]="_getStepLabelId(i)"
4-
[attr.aria-controls]="_getStepContentId(i)"
5-
[attr.aria-selected]="selectedIndex == i"
6-
[tabIndex]="_focusIndex == i ? 0 : -1"
7-
(click)="step.select()"
8-
(keydown)="_onKeydown($event)">
9-
<div class="mat-stepper-index">
10-
{{i + 1}}
11-
</div>
12-
13-
<div class="mat-stepper-label">
14-
<!-- If there is a label template, use it. -->
15-
<ng-container *ngIf="step.stepLabel" [ngTemplateOutlet]="step.stepLabel.template">
16-
</ng-container>
17-
<!-- It there is no label template, fall back to the text label. -->
18-
<div *ngIf="!step.stepLabel">{{step.label}}</div>
19-
</div>
1+
<div #stepHeader *ngFor="let step of _steps; let i = index; let isLast = last"
2+
class="mat-stepper-header" role="tab"
3+
[id]="_getStepLabelId(i)"
4+
[attr.aria-controls]="_getStepContentId(i)"
5+
[attr.aria-selected]="selectedIndex == i"
6+
[tabIndex]="_focusIndex == i ? 0 : -1"
7+
(click)="step.select()"
8+
(keydown)="_onKeydown($event)">
9+
<div class="mat-stepper-index">
10+
{{i + 1}}
11+
</div>
2012

21-
</ng-template>
22-
<div *ngIf="!isLast" class="connector-line"></div>
13+
<div class="mat-stepper-label">
14+
<!-- If there is a label template, use it. -->
15+
<ng-container *ngIf="step.stepLabel" [ngTemplateOutlet]="step.stepLabel.template">
16+
</ng-container>
17+
<!-- It there is no label template, fall back to the text label. -->
18+
<div *ngIf="!step.stepLabel">{{step.label}}</div>
2319
</div>
20+
21+
<div *ngIf="!isLast" class="connector-line"></div>
2422
</div>
23+
2524
<div *ngFor="let step of _steps; let i = index"
2625
class="mat-stepper-content" role="tabpanel"
2726
[id]="_getStepContentId(i)"
2827
[attr.aria-labelledby]="_getStepLabelId(i)"
2928
[attr.aria-expanded]="selectedIndex == i">
3029
<ng-container [ngTemplateOutlet]="step.content"></ng-container>
3130
</div>
31+
<!-- TODO(jwshin): Remove these buttons when stepper-button directives are created. -->
3232
<div>
3333
<button md-button (click)="previous()">Back</button>
3434
<button md-button (click)="next()">Next</button>

src/lib/stepper/stepper-horizontal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {MdStepper} from './stepper';
2020
'class': 'mat-stepper-horizontal',
2121
'role': 'tablist',
2222
},
23-
providers: [{ provide: MdStepper, useExisting: MdHorizontalStepper }]
23+
providers: [{provide: MdStepper, useExisting: MdHorizontalStepper}]
2424
})
2525
export class MdHorizontalStepper extends MdStepper {
2626
/** Steps that the horizontal stepper holds. */

src/lib/stepper/stepper-vertical.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
[attr.aria-labelledby]="_getStepLabelId(i)"
2626
[attr.aria-expanded]="selectedIndex == i">
2727
<ng-container [ngTemplateOutlet]="step.content"></ng-container>
28+
29+
<!-- TODO(jwshin): Remove these buttons when stepper-button directives are created. -->
2830
<div>
2931
<button md-button (click)="previous()">Back</button>
3032
<button md-button (click)="next()">Next</button>

src/lib/stepper/stepper-vertical.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {MdStepper} from './stepper';
2020
'class': 'mat-stepper-vertical',
2121
'role': 'tablist',
2222
},
23-
providers: [{ provide: MdStepper, useExisting: MdVerticalStepper }]
23+
providers: [{provide: MdStepper, useExisting: MdVerticalStepper}]
2424
})
2525
export class MdVerticalStepper extends MdStepper {
2626
/** Steps that the vertical stepper holds. */

src/lib/stepper/stepper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
*/
88

99
import {CdkStepper} from '@angular/cdk';
10-
import {ElementRef, QueryList, ViewChildren} from '@angular/core';
10+
import {
11+
// This import is only used to define a generic type. The current TypeScript version incorrectly
12+
// considers such imports as unused (https://github.com/Microsoft/TypeScript/issues/14953)
13+
// tslint:disable-next-line:no-unused-variable
14+
ElementRef,
15+
QueryList,
16+
ViewChildren
17+
}from '@angular/core';
1118

1219
export class MdStepper extends CdkStepper {
1320
@ViewChildren('stepHeader') _stepHeader: QueryList<ElementRef>;

0 commit comments

Comments
 (0)