@@ -9,7 +9,10 @@ import { Subject } from 'rxjs';
99import { takeUntil } from 'rxjs/operators' ;
1010import { growVerIn , growVerOut } from '../animations/grow' ;
1111import { ToggleAnimationSettings } from '../expansion-panel/toggle-animation-component' ;
12- import { IgxStepperOrienatation , IGX_STEPPER_COMPONENT , IStepToggledEventArgs , IStepTogglingEventArgs } from './common' ;
12+ import {
13+ IgxStepperLabelPosition , IgxStepperOrienatation ,
14+ IgxStepType , IGX_STEPPER_COMPONENT , IStepToggledEventArgs , IStepTogglingEventArgs
15+ } from './common' ;
1316import {
1417 IgxStepIconDirective , IgxStepInvalidIconDirective ,
1518 IgxStepLabelDirective , IgxStepValidIconDirective
@@ -31,6 +34,7 @@ import { IgxStepperService } from './stepper.service';
3134} )
3235export class IgxStepperComponent extends IgxCarouselComponentBase implements OnInit , AfterViewInit , OnDestroy {
3336
37+ /** @hidden @internal **/
3438 @HostBinding ( 'class.igx-stepper' )
3539 public cssClass = 'igx-stepper' ;
3640
@@ -100,7 +104,18 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
100104 * ```
101105 */
102106 @Input ( )
103- public linear = false ;
107+ public get linear ( ) : boolean {
108+ return this . _linear ;
109+ }
110+
111+ public set linear ( value : boolean ) {
112+ this . _linear = value ;
113+ if ( this . _linear ) {
114+ this . calculateLinearDisabledSteps ( ) ;
115+ } else {
116+ this . stepperService . linearDisabledSteps . clear ( ) ;
117+ }
118+ }
104119
105120 /**
106121 * Get/Set the stepper orientation.
@@ -124,9 +139,69 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
124139 this . _orientation = value ;
125140 }
126141
142+ /**
143+ * Get/Set the type of the steps.
144+ *
145+ * ```typescript
146+ * this.stepper.stepType = IgxStepType.Indicator;
147+ * ```
148+ */
149+ @Input ( )
150+ public stepType = IgxStepType . Full ;
151+
152+ /**
153+ * Get/Set the position of the steps label.
154+ *
155+ * ```typescript
156+ * this.stepper.labelPosition = IgxStepperLabelPosition.Top;
157+ * ```
158+ */
159+ @Input ( )
160+ public labelPosition = IgxStepperLabelPosition . Bottom ;
161+
162+ /**
163+ * Get all steps.
164+ *
165+ * ```typescript
166+ * const steps: IgxStepComponent[] = this.stepper.steps;
167+ * ```
168+ */
169+ public get steps ( ) : IgxStepComponent [ ] {
170+ return this . _steps ?. toArray ( ) || [ ] ;
171+ }
172+
173+ /** @hidden @internal */
174+ public get nativeElement ( ) {
175+ return this . element . nativeElement ;
176+ }
177+
178+ /**
179+ * Emitted when the stepper's active step is changing.
180+ *
181+ *```html
182+ * <igx-stepper (activeStepChanging)="handleActiveStepChanging($event)">
183+ * </igx-stepper>
184+ * ```
185+ *
186+ *```typescript
187+ * public handleActiveStepChanging(event: IStepperCancelableEventArgs) {
188+ * if (event.newIndex < event.oldIndex) {
189+ * event.cancel = true;
190+ * }
191+ * }
192+ *```
193+ */
127194 @Output ( )
128195 public activeStepChanging = new EventEmitter < IStepTogglingEventArgs > ( ) ;
129196
197+ /**
198+ * Emitted when the active step is changed.
199+ *
200+ * @example
201+ * ```
202+ * <igx-stepper (activeStepChanged)="handleActiveStepChanged($event)"></igx-stepper>
203+ * ```
204+ */
130205 @Output ( )
131206 public activeStepChanged = new EventEmitter < IStepToggledEventArgs > ( ) ;
132207
@@ -140,6 +215,7 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
140215 private destroy$ = new Subject < void > ( ) ;
141216 private unsubChildren$ = new Subject < void > ( ) ;
142217 private _orientation : IgxStepperOrienatation | string = IgxStepperOrienatation . Vertical ;
218+ private _linear = false ;
143219
144220 constructor (
145221 builder : AnimationBuilder ,
@@ -150,19 +226,6 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
150226 // this.navService.register(this);
151227 }
152228
153- public get steps ( ) : IgxStepComponent [ ] {
154- return this . _steps ?. toArray ( ) || [ ] ;
155- }
156-
157- /** @hidden @internal */
158- public get nativeElement ( ) {
159- return this . element . nativeElement ;
160- }
161-
162- /** @hidden @internal */
163- public handleKeydown ( event : KeyboardEvent ) {
164- // this.navService.handleKeydown(event);
165- }
166229
167230 /** @hidden @internal */
168231 public ngOnInit ( ) {
@@ -196,6 +259,49 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
196259 this . destroy$ . complete ( ) ;
197260 }
198261
262+ /** @hidden @internal */
263+ public handleKeydown ( event : KeyboardEvent ) {
264+ // this.navService.handleKeydown(event);
265+ }
266+
267+ /** @hidden @internal */
268+ public calculateLinearDisabledSteps ( ) {
269+ if ( this . stepperService . activeStep . isValid ) {
270+ const firstRequiredIndex = this . stepperService . getNextRequiredStep ( ) ;
271+ if ( firstRequiredIndex !== - 1 ) {
272+ this . steps . forEach ( s => {
273+ if ( s . index > this . stepperService . activeStep . index ) {
274+ if ( s . index <= firstRequiredIndex ) {
275+ this . stepperService . linearDisabledSteps . delete ( s ) ;
276+ } else {
277+ this . stepperService . linearDisabledSteps . add ( s ) ;
278+ }
279+ }
280+ } ) ;
281+ } else {
282+ this . stepperService . linearDisabledSteps . clear ( ) ;
283+ }
284+ } else {
285+ this . steps . forEach ( s => {
286+ if ( s . index > this . stepperService . activeStep . index ) {
287+ this . stepperService . linearDisabledSteps . add ( s ) ;
288+ }
289+ } ) ;
290+ }
291+ }
292+
293+ public navigateTo ( index : number ) {
294+ if ( ! this . steps [ index ] ) {
295+ return ;
296+ }
297+ const step = this . steps [ index ] ;
298+ if ( step . disabled || this . stepperService . linearDisabledSteps . has ( step ) ) {
299+ return ;
300+ }
301+
302+ this . stepperService . expand ( step ) ;
303+ }
304+
199305 public playHorizontalAnimations ( ) {
200306 this . previousItem = this . stepperService . previousActiveStep ;
201307 this . currentItem = this . stepperService . activeStep ;
0 commit comments