flexacore-ui-dev
Version:
Universal UI Framework for CDN, React, Angular, Vue, Svelte with TypeScript support
94 lines (88 loc) • 2.76 kB
text/typescript
import { Component, Input, Output, EventEmitter, ContentChildren, QueryList, AfterContentInit } from '@angular/core';
export class FCStepComponent {
title: string = '';
description: string = '';
active: boolean = false;
completed: boolean = false;
index: number = 0;
}
export class FCStepperComponent implements AfterContentInit {
steps!: QueryList<FCStepComponent>;
currentStep: number = 0;
showNavigation: boolean = true;
currentStepChange = new EventEmitter<number>();
ngAfterContentInit() {
this.updateSteps();
}
updateSteps() {
this.steps.forEach((step, index) => {
step.index = index;
step.active = index === this.currentStep;
step.completed = index < this.currentStep;
});
}
next() {
if (this.currentStep < this.steps.length - 1) {
this.currentStep++;
this.updateSteps();
this.currentStepChange.emit(this.currentStep);
}
}
previous() {
if (this.currentStep > 0) {
this.currentStep--;
this.updateSteps();
this.currentStepChange.emit(this.currentStep);
}
}
}