UNPKG

@y3krulez/angular-archwizard

Version:

The port of angular-archwizard, supporting IVY and thus being compatible with Angular16+

96 lines (95 loc) 4.82 kB
import { EventEmitter } from '@angular/core'; import { NavigationMode } from './navigation-mode.interface'; import { WizardComponent } from '../components/wizard.component'; /** * Base implementation of [[NavigationMode]] * * Note: Built-in [[NavigationMode]] classes should be stateless, allowing the library user to easily create * an instance of a particular [[NavigationMode]] class and pass it to `<aw-wizard [navigationMode]="...">`. * * @author Marc Arndt */ export declare abstract class BaseNavigationMode implements NavigationMode { /** * Checks, whether a wizard step, as defined by the given destination index, can be transitioned to. * * This method controls navigation by [[goToStep]], [[goToPreviousStep]], and [[goToNextStep]] directives. * Navigation by navigation bar is governed by [[isNavigable]]. * * In this implementation, a destination wizard step can be entered if: * - it exists * - the current step can be exited in the direction of the destination step * - the destination step can be entered in the direction from the current step * * Subclasses can impose additional restrictions, see [[canTransitionToStep]]. * * @param wizard The wizard component to operate on * @param destinationIndex The index of the destination step * @returns A [[Promise]] containing `true`, if the destination step can be transitioned to and `false` otherwise */ canGoToStep(wizard: WizardComponent, destinationIndex: number): Promise<boolean>; /** * Imposes additional restrictions for `canGoToStep` in current navigation mode. * * The base implementation allows transition iff the given step is navigable from the navigation bar (see `isNavigable`). * However, in some navigation modes `canTransitionToStep` can be more relaxed to allow navigation to certain steps * by previous/next buttons, but not using the navigation bar. * * @param wizard The wizard component to operate on * @param destinationIndex The index of the destination step * @returns `true`, if the destination step can be transitioned to and `false` otherwise */ protected canTransitionToStep(wizard: WizardComponent, destinationIndex: number): boolean; /** * Tries to transition to the wizard step, as denoted by the given destination index. * * When entering the destination step, the following actions are done: * - the old current step is set as completed * - the old current step is set as unselected * - the old current step is exited * - the destination step is set as selected * - the destination step is entered * * When the destination step couldn't be entered, the following actions are done: * - the current step is exited and entered in the direction `MovingDirection.Stay` * * @param wizard The wizard component to operate on * @param destinationIndex The index of the destination wizard step, which should be entered * @param preFinalize An event emitter, to be called before the step has been transitioned * @param postFinalize An event emitter, to be called after the step has been transitioned */ goToStep(wizard: WizardComponent, destinationIndex: number, preFinalize?: EventEmitter<void>, postFinalize?: EventEmitter<void>): void; /** * Transitions the wizard to the given step index. * * Can perform additional actions in particular navigation mode implementations. * * @param wizard The wizard component to operate on * @param destinationIndex The index of the destination wizard step */ protected transition(wizard: WizardComponent, destinationIndex: number): void; /** * @inheritDoc */ abstract isNavigable(WizardComponent: WizardComponent, destinationIndex: number): boolean; /** * Resets the state of this wizard. * * A reset transitions the wizard automatically to the first step and sets all steps as incomplete. * In addition the whole wizard is set as incomplete. * * @param wizard The wizard component to operate on */ reset(wizard: WizardComponent): void; /** * Checks if wizard configuration allows to perform reset. * * A check failure is indicated by throwing an `Error` with the message discribing the discovered misconfiguration issue. * * Can include additional checks in particular navigation mode implementations. * * @param wizard The wizard component to operate on * @throws An `Error` is thrown, if a micconfiguration issue is discovered. */ protected ensureCanReset(wizard: WizardComponent): void; }