diff --git a/src/cdk/stepper/index.ts b/src/cdk/stepper/index.ts index 58ccf40404b2..cfb2fec4dc26 100644 --- a/src/cdk/stepper/index.ts +++ b/src/cdk/stepper/index.ts @@ -10,13 +10,15 @@ import {NgModule} from '@angular/core'; import {CdkStepper, CdkStep} from './stepper'; import {CommonModule} from '@angular/common'; import {CdkStepLabel} from './step-label'; +import {CdkStepperNext, CdkStepperPrevious} from './stepper-button'; @NgModule({ imports: [CommonModule], - exports: [CdkStep, CdkStepper, CdkStepLabel], - declarations: [CdkStep, CdkStepper, CdkStepLabel] + exports: [CdkStep, CdkStepper, CdkStepLabel, CdkStepperNext, CdkStepperPrevious], + declarations: [CdkStep, CdkStepper, CdkStepLabel, CdkStepperNext, CdkStepperPrevious] }) export class CdkStepperModule {} export * from './stepper'; export * from './step-label'; +export * from './stepper-button'; diff --git a/src/cdk/stepper/stepper-button.ts b/src/cdk/stepper/stepper-button.ts new file mode 100644 index 000000000000..c63d8c822eef --- /dev/null +++ b/src/cdk/stepper/stepper-button.ts @@ -0,0 +1,28 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {Directive} from '@angular/core'; +import {CdkStepper} from './stepper'; + +/** Button that moves to the next step in a stepper workflow. */ +@Directive({ + selector: 'button[cdkStepperNext]', + host: {'(click)': '_stepper.next()'} +}) +export class CdkStepperNext { + constructor(public _stepper: CdkStepper) { } +} + +/** Button that moves to the previous step in a stepper workflow. */ +@Directive({ + selector: 'button[cdkStepperPrevious]', + host: {'(click)': '_stepper.previous()'} +}) +export class CdkStepperPrevious { + constructor(public _stepper: CdkStepper) { } +} diff --git a/src/demo-app/stepper/stepper-demo.html b/src/demo-app/stepper/stepper-demo.html index 6b7b9944da9d..89d64a58574f 100644 --- a/src/demo-app/stepper/stepper-demo.html +++ b/src/demo-app/stepper/stepper-demo.html @@ -4,6 +4,10 @@

Horizontal Stepper Demo

+
+ + +
@@ -14,6 +18,10 @@

Horizontal Stepper Demo with Templated Label

+
+ + +
@@ -23,5 +31,9 @@

Vertical Stepper Demo

+
+ + +
diff --git a/src/lib/core/compatibility/compatibility.ts b/src/lib/core/compatibility/compatibility.ts index 3b6f0bf3cda5..17b877583d02 100644 --- a/src/lib/core/compatibility/compatibility.ts +++ b/src/lib/core/compatibility/compatibility.ts @@ -35,6 +35,8 @@ export const MAT_ELEMENTS_SELECTOR = ` [matDialogTitle], [matLine], [matStepLabel], + [matStepperNext], + [matStepperPrevious], [matTabLabel], [matTabLink], [matTabNav], @@ -105,6 +107,8 @@ export const MD_ELEMENTS_SELECTOR = ` [mdDialogTitle], [mdLine], [mdStepLabel], + [mdStepperNext], + [mdStepperPrevious], [mdTabLabel], [mdTabLink], [mdTabNav], diff --git a/src/lib/stepper/index.ts b/src/lib/stepper/index.ts index 844198c1e7cb..8fffc8b2a28e 100644 --- a/src/lib/stepper/index.ts +++ b/src/lib/stepper/index.ts @@ -16,11 +16,14 @@ import {MdStep, MdStepper} from './stepper'; import {CdkStepperModule} from '@angular/cdk'; import {MdCommonModule} from '../core'; import {MdStepLabel} from './step-label'; +import {MdStepperNext, MdStepperPrevious} from './stepper-button'; @NgModule({ imports: [MdCommonModule, CommonModule, PortalModule, MdButtonModule, CdkStepperModule], - exports: [MdCommonModule, MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper], - declarations: [MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper], + exports: [MdCommonModule, MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper, + MdStepperNext, MdStepperPrevious], + declarations: [MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper, + MdStepperNext, MdStepperPrevious], }) export class MdStepperModule {} @@ -28,3 +31,4 @@ export * from './stepper-horizontal'; export * from './stepper-vertical'; export * from './step-label'; export * from './stepper'; +export * from './stepper-button'; diff --git a/src/lib/stepper/stepper-button.ts b/src/lib/stepper/stepper-button.ts new file mode 100644 index 000000000000..d17d72fe3f04 --- /dev/null +++ b/src/lib/stepper/stepper-button.ts @@ -0,0 +1,27 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {Directive} from '@angular/core'; +import {CdkStepper, CdkStepperNext, CdkStepperPrevious} from '@angular/cdk'; +import {MdStepper} from './stepper'; + +/** Button that moves to the next step in a stepper workflow. */ +@Directive({ + selector: 'button[mdStepperNext], button[matStepperNext]', + host: {'(click)': '_stepper.next()'}, + providers: [{provide: CdkStepper, useExisting: MdStepper}] +}) +export class MdStepperNext extends CdkStepperNext { } + +/** Button that moves to the previous step in a stepper workflow. */ +@Directive({ + selector: 'button[mdStepperPrevious], button[matStepperPrevious]', + host: {'(click)': '_stepper.previous()'}, + providers: [{provide: CdkStepper, useExisting: MdStepper}] +}) +export class MdStepperPrevious extends CdkStepperPrevious { } diff --git a/src/lib/stepper/stepper-horizontal.html b/src/lib/stepper/stepper-horizontal.html index 937de1074045..e69836b862f1 100644 --- a/src/lib/stepper/stepper-horizontal.html +++ b/src/lib/stepper/stepper-horizontal.html @@ -28,8 +28,3 @@ [attr.aria-expanded]="selectedIndex == i"> - -
- - -
diff --git a/src/lib/stepper/stepper-vertical.html b/src/lib/stepper/stepper-vertical.html index 1ea8ef9e6789..993ea0cdb04d 100644 --- a/src/lib/stepper/stepper-vertical.html +++ b/src/lib/stepper/stepper-vertical.html @@ -25,11 +25,5 @@ [attr.aria-labelledby]="_getStepLabelId(i)" [attr.aria-expanded]="selectedIndex == i"> - - -
- - -