import { ReactiveController, ReactiveControllerHost } from 'lit'; import { PairboFormControl } from './pairbo-element'; import { PboButton } from '../components/main'; export declare const formCollections: WeakMap>; /** * Interface for defining how a form control behaves. * * This interface provides configuration options for a form control's behavior, * including retrieving its associated form, handling values, and managing validation. * * @interface FormControlControllerOptions * * @property {function} form - Returns the parent form element associated with the control. * @property {function} name - Returns the name identifier of the control. * @property {function} defaultValue - Returns the initial/default value of the control. * @property {function} value - Returns the current value(s) of the control. If the control supports multiple values (e.g., multi-select), it returns an array. * @property {function} disabled - Determines if the control is currently disabled. * @property {function} reportValidity - Validates the control and returns `true` if valid, otherwise shows an error message. * @property {function} checkValidity - Validates the control and returns `true` if valid, `false` if invalid, without displaying an error. * @property {function} setValue - Updates the value of the control programmatically. * @property {string[]} assumeInteractionOn - List of event names that indicate user interaction with the control. */ export interface FormControlControllerOptions { form: (input: PairboFormControl) => HTMLFormElement | null; name: (input: PairboFormControl) => string; defaultValue: (input: PairboFormControl) => unknown; value: (input: PairboFormControl) => unknown | unknown[]; disabled: (input: PairboFormControl) => boolean; reportValidity: (input: PairboFormControl) => boolean; checkValidity: (input: PairboFormControl) => boolean; setValue: (input: PairboFormControl, value: unknown) => void; assumeInteractionOn: string[]; } /** * A controller class that manages form control behavior in reactive components. * Implements the ReactiveController interface to handle form-related functionality. * * @implements {ReactiveController} * * @property {PairboFormControl & ReactiveControllerHost} host - The host element that this controller is attached to * @property {HTMLFormElement | null | undefined} form - The associated form element * @property {FormControlControllerOptions} options - Configuration options for the form control * * @example * ```typescript * const controller = new FormControlController(hostElement, { * // Custom options * }); * ``` * * @remarks * This controller provides form control functionality including: * - Form attachment and detachment * - Form validation handling * - Form data submission * - Form reset handling * - User interaction tracking * - Custom validity states * * The controller automatically manages: * - Form element lifecycle * - Form validation overrides * - Form data collection * - User interaction states * - Form submission and reset events * * @fires pbo-invalid - Emitted when the form control becomes invalid */ export declare class FormControlController implements ReactiveController { host: PairboFormControl & ReactiveControllerHost; form?: HTMLFormElement | null; options: FormControlControllerOptions; constructor(host: PairboFormControl & ReactiveControllerHost, options?: Partial); hostConnected(): void; hostDisconnected(): void; hostUpdated(): void; private attachForm; private detachForm; private handleFormData; private handleFormSubmit; private handleFormReset; private handleInteraction; private checkFormValidity; private reportFormValidity; private setUserInteracted; private doAction; /** Returns the associated `
` element, if one exists. The method to get the form is init in the construct, and the initialization is in the `hostConnected()`*/ getForm(): HTMLFormElement | null; reset(submitter?: HTMLInputElement | PboButton): void; submit(submitter?: HTMLInputElement | PboButton): void; setValidity(isValid: boolean): void; updateValidity(): void; emitInvalidEvent(originalInvalidEvent?: Event): void; } export declare const validValidityState: ValidityState; export declare const valueMissingValidityState: ValidityState; export declare const customErrorValidityState: ValidityState;