@@ -9,7 +9,10 @@ import { Subject } from 'rxjs';
9
9
import { takeUntil } from 'rxjs/operators' ;
10
10
import { growVerIn , growVerOut } from '../animations/grow' ;
11
11
import { 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' ;
13
16
import {
14
17
IgxStepIconDirective , IgxStepInvalidIconDirective ,
15
18
IgxStepLabelDirective , IgxStepValidIconDirective
@@ -31,6 +34,7 @@ import { IgxStepperService } from './stepper.service';
31
34
} )
32
35
export class IgxStepperComponent extends IgxCarouselComponentBase implements OnInit , AfterViewInit , OnDestroy {
33
36
37
+ /** @hidden @internal **/
34
38
@HostBinding ( 'class.igx-stepper' )
35
39
public cssClass = 'igx-stepper' ;
36
40
@@ -100,7 +104,18 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
100
104
* ```
101
105
*/
102
106
@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
+ }
104
119
105
120
/**
106
121
* Get/Set the stepper orientation.
@@ -124,9 +139,69 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
124
139
this . _orientation = value ;
125
140
}
126
141
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
+ */
127
194
@Output ( )
128
195
public activeStepChanging = new EventEmitter < IStepTogglingEventArgs > ( ) ;
129
196
197
+ /**
198
+ * Emitted when the active step is changed.
199
+ *
200
+ * @example
201
+ * ```
202
+ * <igx-stepper (activeStepChanged)="handleActiveStepChanged($event)"></igx-stepper>
203
+ * ```
204
+ */
130
205
@Output ( )
131
206
public activeStepChanged = new EventEmitter < IStepToggledEventArgs > ( ) ;
132
207
@@ -140,6 +215,7 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
140
215
private destroy$ = new Subject < void > ( ) ;
141
216
private unsubChildren$ = new Subject < void > ( ) ;
142
217
private _orientation : IgxStepperOrienatation | string = IgxStepperOrienatation . Vertical ;
218
+ private _linear = false ;
143
219
144
220
constructor (
145
221
builder : AnimationBuilder ,
@@ -150,19 +226,6 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
150
226
// this.navService.register(this);
151
227
}
152
228
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
- }
166
229
167
230
/** @hidden @internal */
168
231
public ngOnInit ( ) {
@@ -196,6 +259,49 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
196
259
this . destroy$ . complete ( ) ;
197
260
}
198
261
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
+
199
305
public playHorizontalAnimations ( ) {
200
306
this . previousItem = this . stepperService . previousActiveStep ;
201
307
this . currentItem = this . stepperService . activeStep ;
0 commit comments