import { Component, computed, signal } from '@angular/core'; import { ButtonComponent, StepDefDirective, type StepDefinition, StepperComponent, TextInputComponent, } from '@africanies/africanies-ui'; import { DemoSectionComponent } from '../shared/demo-section.component'; import { PageHeaderComponent } from '../shared/page-header.component'; import { STEPPER_FREE, STEPPER_LINEAR } from '../snippets'; /** * */ @Component({ selector: 'app-stepper-page', standalone: true, imports: [ StepperComponent, StepDefDirective, ButtonComponent, TextInputComponent, PageHeaderComponent, DemoSectionComponent, ], template: `
Step {{ linearIndex() + 1 }} of {{ linearSteps().length }}

Origin and destination for this shipment.

Describe what you are shipping.

Review

  • {{ origin() || '—' }} → {{ destination() || '—' }}
  • {{ commodity() || 'No commodity set' }}

Account details step body.

Billing step body.

Confirmation step body.

`, }) export class StepperPage { protected readonly linearIndex = signal(0); protected readonly freeIndex = signal(0); protected readonly routeValid = signal(false); protected readonly origin = signal('Lagos'); protected readonly destination = signal(''); protected readonly commodity = signal(''); protected readonly linearSteps = computed(() => [ { key: 'route', label: 'Route', isValid: this.routeValid() }, { key: 'cargo', label: 'Cargo', isValid: true }, { key: 'review', label: 'Review' }, ]); protected readonly freeSteps: StepDefinition[] = [ { key: 'account', label: 'Account' }, { key: 'billing', label: 'Billing' }, { key: 'confirm', label: 'Confirm' }, ]; protected readonly linearCode = STEPPER_LINEAR; protected readonly freeCode = STEPPER_FREE; protected canGoNext(): boolean { const current = this.linearSteps()[this.linearIndex()]; return current?.isValid !== false; } }