import { ReactiveController, ReactiveControllerHost } from "lit"; import { SgdsCheckbox, SgdsInput } from "../components"; /** * SGDS custom form validation methods and behaviours */ export declare class InputValidationController implements ReactiveController { host: ReactiveControllerHost & HTMLElement; _internals: ElementInternals; validationError: keyof ValidityState; options: InputValidationControllerOptions; constructor(host: ReactiveControllerHost & HTMLElement, options?: Partial); hostConnected(): void; hostDisconnected(): void; /** * Prevents the native browser error message pop up when reportValidity() called by * associated form or the component's reportValidity during constraint validation * Sets invalid reactive prop to true */ handleInvalid(e: Event): void; /** * Sets invalid to false when invoked and * Updates the ValidityState based on new value, but * does not update invalid reactive prop * @param e */ handleInput(e: Event): void; /** * Validate the input's new value after onChange and * update invalid reactive prop * @param e */ handleChange(e: Event): void; get form(): HTMLFormElement; get validity(): ValidityState; get validationMessage(): string; get willValidate(): boolean; /** * Checks the validity and updates the invalid reactive prop of form components */ updateInvalidState(): void; /** * Resets the ValidityState of the control */ resetValidity(): void; /** * Reports the validity */ checkValidity(): boolean; /** * Reports the validity with a error popup message */ reportValidity(): boolean; setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void; /** * Sets the form control value into FormData, * making the value of control accessible via FormData */ setFormValue(): void; /** * Updates the ValidityState of the input in form component at current state */ validateInput(input: any): void; } export interface InputValidationControllerOptions { /** A function that sets the value of host invalid reactive prop */ setInvalid: (host: ReactiveControllerHost & HTMLElement, value: boolean) => void; /** A function that gets the value of host value reactive prop */ value: (host: ReactiveControllerHost & HTMLElement) => unknown; /** A function that gets the input control of host value reactive prop */ input: (host: ReactiveController & HTMLElement) => HTMLInputElement | SgdsInput | SgdsCheckbox; }