import { GdsElement } from '../../gds-element'; import './form-request-submit-polyfill'; export interface GdsValidator { /** * Validate the form control element. Should return the validity state and an optional validation message. */ validate(element: GdsFormControlElement): [ValidityState, string] | undefined; } /** * Abstract base class for Green Core form controls. * * This class sets up the form-associated custom element API, along with some * other common form control functionality that all Green Core form controls share. * * @internal * * @event gds-validity-state - Dispatched when the validity state of the form control is changed by a validator. */ export declare abstract class GdsFormControlElement extends GdsElement implements Partial> { #private; static formAssociated: boolean; constructor(); connectedCallback(): void; /** * A validator that can be used to validate the form control and set an error message. */ validator?: GdsValidator; /** * The required attribute can be used to communicate to users of assistive technology that the control is required. Validation still needs to be done in a validator or equivalent. */ required: boolean; /** * This can be used to manually control the error message that will be displayed * when the control is invalid. */ errorMessage: string; /** * Validation state of the form control. Setting this to true triggers the invalid state of the control. * * @attr aria-invalid */ set invalid(value: boolean); get invalid(): boolean; /** * The label of the form control. */ label: string; /** * Get or set the value of the form control. */ get value(): ValueT | undefined; set value(value: ValueT | undefined); protected _internalValue?: ValueT; name: string; /** * If the input is Disabled */ disabled: boolean; /** * The form element that the form control is associated with. */ get form(): HTMLFormElement | null; get validity(): ValidityState; get validationMessage(): string; get willValidate(): boolean; checkValidity(): boolean; reportValidity(): boolean; private __handleValueChange; protected formResetCallback(): void; protected formAssociatedCallback(form?: HTMLFormElement): void; protected _handleFormSubmit(e: Event): void; /** * This should return a reference to the HTML element that the browser will refer to when the form control is invalid. * The reference is used when setting the validity state in ElementInternals. * For reference: https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setValidity#anchor */ protected abstract _getValidityAnchor(): HTMLElement; }