@uplink-protocol/form-controller
Version:
Reactive multi-step form controller with dynamic validation and state management
44 lines (43 loc) • 1.73 kB
TypeScript
import { BaseService } from './base.service';
import { ConfigService } from './config.service';
/**
* Service for managing multi-step form navigation
*/
export declare class StepperService extends BaseService<number> {
private configService;
constructor(initialStepIndex: number, configService: ConfigService);
/**
* Navigate to the next step if possible
* @param validateCallback Optional validation callback that determines if navigation is allowed
* @returns New step index or current step if navigation isn't possible
*/
nextStep(validateCallback?: () => boolean): number;
/**
* Validate current step and navigate to next if valid
* @param currentStepId Current step ID for touch marking
* @param markStepTouched Function to mark all fields in step as touched
* @param validateStep Function to validate the current step
* @returns New step index or current step if validation fails
*/ validateAndNext(currentStepId: string, markStepTouched: (stepId: string, touched: boolean) => void, validateStep: (showErrors: boolean) => boolean): number;
/**
* Navigate to the previous step if possible
* @returns New step index or 0 if already at first step
*/
prevStep(): number;
/**
* Go to a specific step by index
* @param stepIndex Target step index
* @returns True if navigation was successful, false otherwise
*/
goToStep(stepIndex: number): boolean;
/**
* Check if currently on the first step
* @returns True if on first step
*/
get isFirstStep(): boolean;
/**
* Check if currently on the last step
* @returns True if on last step
*/
get isLastStep(): boolean;
}