igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
68 lines (67 loc) • 3.17 kB
TypeScript
import type { PropertyValues } from 'lit';
import type IgcStepComponent from '../step.js';
type StepState = {
linearDisabled: boolean;
previousCompleted: boolean;
visited: boolean;
};
declare class StepperState {
private readonly _state;
private _steps;
private _activeStep?;
linear: boolean;
/** Returns all registered step components. */
get steps(): readonly IgcStepComponent[];
/** Returns the currently active step. */
get activeStep(): IgcStepComponent | undefined;
/** Returns all steps that are currently accessible (not disabled or linear-disabled). */
get accessibleSteps(): IgcStepComponent[];
/**
* Sets the state of a given step component.
*
* If the step already has an existing state, it merges the new state with the existing one.
* If the step does not have an existing state, it initializes it with default values and then applies the new state.
*
* After updating the state, it requests an update on the step component to reflect the changes in the UI.
*/
set(step: IgcStepComponent, state: Partial<StepState>): void;
/** Checks if a given step component has an associated state. */
has(step: IgcStepComponent): boolean;
/** Retrieves the state of a given step component. */
get(step: IgcStepComponent): StepState | undefined;
/** Deletes the state of a given step component. */
delete(step: IgcStepComponent): boolean;
/**
* Determines if a given step component is accessible based on its `disabled` state
* and the `linearDisabled` state from the stepper state management.
*/
isAccessible(step: IgcStepComponent): boolean;
/** Updates the registered steps collection. */
setSteps(steps: IgcStepComponent[]): void;
/** Changes the active step, deactivating the previous one and marking the new one as visited. */
changeActiveStep(step: IgcStepComponent): void;
/** Activates the first non-disabled step. */
activateFirstStep(): void;
/** Returns the next or previous accessible step relative to the active step. */
getAdjacentStep(next?: boolean): IgcStepComponent | undefined;
/** Synchronizes the `active` and `previousCompleted` state across all steps. */
syncState(): void;
/**
* Sets the visited state for all steps based on the current active step and the linear mode.
*/
setVisitedState(value: boolean): void;
/** Computes and applies the linear-disabled state for all steps. */
setLinearState(): void;
/** Handles step property changes, updating active step tracking and re-syncing state. */
onStepPropertyChanged(step: IgcStepComponent, changed: PropertyValues<IgcStepComponent>): void;
/** Processes a change in the steps collection, resolving the active step and syncing state. */
stepsChanged(): void;
/** Resets all step states and activates the first step. */
reset(): void;
}
/**
* Creates a new instance of the StepperState class, which manages the state of steps in a stepper component.
*/
declare function createStepperState(): StepperState;
export { createStepperState };
export type { StepperState };