@uplink-protocol/form-controller
Version:
Reactive multi-step form controller with dynamic validation and state management
51 lines (50 loc) • 1.68 kB
TypeScript
import { BaseService } from './base.service';
import { FormConfig } from '../interfaces/form-config.interface';
import { FormStep } from '../interfaces/form-step.interface';
/**
* Service for managing form configuration
*/
export declare class ConfigService extends BaseService<FormConfig> {
constructor(initialConfig: FormConfig);
/**
* Update the entire form configuration
* @param newConfig New form configuration
*/
updateConfig(newConfig: FormConfig): void;
/**
* Update the form configuration and reset related state
* @param newConfig New form configuration
* @param resetCallback Function to reset the form state
*/
updateConfigAndReset(newConfig: FormConfig, resetCallback: () => void): void;
/**
* Add a new step to the form configuration
* @param step New form step
* @param index Position to insert the step (defaults to end)
* @returns New steps length
*/
addStep(step: FormStep, index?: number): number;
/**
* Remove a step from the form configuration
* @param stepId ID of the step to remove
* @returns Success flag
*/
removeStep(stepId: string): boolean;
/**
* Get the step by ID
* @param stepId Step ID
* @returns Form step or undefined if not found
*/
getStepById(stepId: string): FormStep | undefined;
/**
* Get step by index
* @param index Step index
* @returns Form step or undefined if index is out of bounds
*/
getStepByIndex(index: number): FormStep | undefined;
/**
* Get total number of steps
* @returns Total number of steps
*/
get totalSteps(): number;
}