/** * @license * Copyright 2023 Nuraly, Laabidi Aymen * SPDX-License-Identifier: MIT */ import { ReactiveControllerHost } from 'lit'; import { TemplateResult } from 'lit'; import { InputHost } from './base.controller.js'; import { BaseValidationController } from '@nuralyui/common/controllers'; import { ValidationRule, InputValidationResult } from '../input.types.js'; import { ValidationState } from './state.controller.js'; /** * Validation event detail interface */ export interface InputValidationEventDetail { isValid: boolean; validationMessage: string; validationState: ValidationState; errors: string[]; warnings: string[]; validationResult: InputValidationResult; } /** * Extended input host interface for validation */ export interface InputValidationHost extends InputHost { rules: ValidationRule[]; validateOnChangeInput: boolean; validateOnBlurInput: boolean; validationTrigger: 'change' | 'blur' | 'submit'; hasFeedback: boolean; allowWarnings: boolean; validationDebounce?: number; maxLength?: number; min?: string; max?: string; state: string; validationMessage?: string; } /** * Validation controller manages all validation logic for input components * This controller handles: * - Rule-based validation (required, patterns, custom validators, etc.) * - Validation timing (change, blur, submit) * - Validation state management * - Error and warning messages * - Integration with form validation */ export declare class InputValidationController extends BaseValidationController { private stateController; private get validationHost(); /** * Get validation state */ get isValid(): boolean; /** * Get validation message */ get validationMessage(): string; /** * Get current validation state */ get validationState(): string; /** * Get validation result */ get validationResult(): InputValidationResult; /** * Check if currently validating */ get isValidating(): boolean; /** * Initialize validation rules based on input properties */ hostConnected(): void; /** * Handle host updates - trigger validation if needed */ hostUpdated(): void; /** * Setup default validation rules based on input properties */ setupValidationRules(): void; /** * Validate the input value */ validate(): boolean; /** * Validate on value change */ validateOnChange(): void; /** * Validate on blur */ validateOnBlur(): void; /** * Add validation rule dynamically (input-specific rules) */ addInputRule(rule: ValidationRule): void; /** * Remove validation rule */ removeInputRule(predicate: (rule: ValidationRule) => boolean): void; /** * Clear all validation rules */ clearInputRules(): void; /** * Check if any rules have async validators */ private hasAsyncValidators; /** * Check if a validator function is async (returns a Promise) */ private isValidatorAsync; /** * Perform async validation */ private performAsyncValidation; /** * Validate a single async rule */ private validateAsyncRule; /** * Reset validation state */ reset(): void; /** * Get current validation status */ getValidationStatus(): { isValid: boolean; isValidating: boolean; errors: string[]; warnings: string[]; validationResult: InputValidationResult; }; /** * Set validation result externally (for form integration) */ setValidationStatus(result: InputValidationResult): void; /** * Perform detailed validation with warnings and errors */ private performDetailedValidation; /** * Validate a single rule */ private validateRule; /** * Validate value type */ private validateType; /** * Check if value is empty */ private isValueEmpty; /** * Check if two rules are the same type */ private isSameRuleType; /** * Set validation result and dispatch event */ private setValidationResult; /** * Update host component validation state */ private updateHostValidationState; /** * Dispatch validation event */ private dispatchInputValidationEvent; /** * Get validation classes for CSS styling */ getValidationClasses(): Record; /** * Check if validation feedback should be shown */ hasValidationFeedback(): boolean; /** * Render validation feedback icon */ renderValidationIcon(): TemplateResult | string; /** * Render validation message */ renderValidationMessage(): TemplateResult | string; /** * Clear debounce timer (delegate to state controller) */ clearDebounceTimer(): void; /** * Get validation state for external components */ getValidationRenderState(): { classes: Record; hasValidationFeedback: boolean; isValidating: boolean; validationResult: InputValidationResult; validationState: ValidationState; }; } //# sourceMappingURL=validation.controller.d.ts.map