import { LitElement } from "lit-element"; import { EventListenerSubscription } from "../../util/event"; export declare type FormElement = (HTMLInputElement | HTMLOutputElement | HTMLButtonElement | HTMLObjectElement | HTMLSelectElement | HTMLTextAreaElement) & { value: string; }; export interface IFormElementBehaviorProperties { disabled: boolean; value: string; readonly: boolean; required: boolean; name?: string; } /** * Provides form element behavior that interacts with forms. * The classes that extends the FormElementBehavior function must implement a * render function that adds a native form element with the ID of .formElementId to the shadow root. * This form element will be added to the light DOM so it can interact with the parent form. * An example of where this is absolutely amazing is when buttons need to trigger auto error notifications * in input elements. It also allows the user to user the constraint validation API. */ export declare abstract class FormElementBehavior extends LitElement implements IFormElementBehaviorProperties { static styles: import("lit-element").CSSResult[]; /** * Disables the element. * @attr */ disabled: boolean; /** * Makes the element readonly (disabled but tabbable) * @attr */ readonly: boolean; /** * Makes the element required in a form context. * @attr */ required: boolean; /** * Name of the native form element. * @attr */ name?: string; /** * Value of the form element. * @attr * @param value */ value: string; /** * Initial value is only set if the form element doesn't exist which will be the case * if it is set before the first update. */ protected initialValue?: string; /** * Id of the native form element. */ protected formElementId: string; /** * Active listeners on the element. */ protected listeners: EventListenerSubscription[]; /** * Native form element. */ protected $formElement: FormElement; /** * Message for the current validation. */ get validationMessage(): string; /** * Returns whether the nativeInput is valid or not. * @returns {boolean} */ get valid(): boolean; /** * Returns the validity state. */ get validity(): ValidityState; /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ get willValidate(): boolean; /** * Returns the associated form of the native form element. */ get form(): HTMLFormElement | null; /** * Checks the validity of the form element. */ checkValidity(): boolean; /** * Sets a custom validity on the form element. * @param error */ setCustomValidity(error: string): void; /** * When the form element first updates we add the form element to the light DOM. * @param props */ protected firstUpdated(props: Map): void; /** * Tears down the component. */ disconnectedCallback(): void; /** * Responds to property changes. * @param props */ protected updated(props: Map): void; /** * Updates the tabindex. */ protected updateTabindex(props: Map): void; /** * Returns the value of the form element. */ protected getFormItemValue(): string; /** * Queries the form element from the shadow root. */ protected queryFormElement(): FormElement; }