igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
129 lines (128 loc) • 5.01 kB
TypeScript
import type { LitElement } from 'lit';
import type { Validator } from '../../validators.js';
export type FormRestoreMode = 'autocomplete' | 'restore';
export type FormValueType = string | File | FormData | null;
export type IgcFormControl = LitElement & (FormAssociatedElementInterface | FormAssociatedCheckboxElementInterface);
declare class BaseFormAssociatedElement {
static readonly formAssociated: boolean;
private __internals;
protected _formValue: unknown;
protected _dirty: boolean;
protected _pristine: boolean;
protected _disabled: boolean;
protected _invalid: boolean;
protected get __validators(): Validator[];
/**
* The disabled state of the component.
* @attr
* @default false
*/
disabled: boolean;
/**
* Sets the control into invalid state (visual state only).
* @attr
* @default false
*/
invalid: boolean;
/**
* The name attribute of the control.
* @attr
*/
name: string;
/** Returns the HTMLFormElement associated with this element. */
get form(): HTMLFormElement | null;
/**
* Returns a ValidityState object which represents the different validity states
* the element can be in, with respect to constraint validation.
*/
get validity(): ValidityState;
/** A string containing the validation message of this element. */
get validationMessage(): string;
/**
* A boolean value which returns true if the element is a submittable element
* that is a candidate for constraint validation.
*/
get willValidate(): boolean;
/**
* Sets the default value of the component.
* Called in `attributeChangedCallback`(i.e. when the `value` attribute of the control is set).
*/
protected _setDefaultValue(current: string | null): void;
/**
* Called when the associated parent form is reset.
*/
protected _restoreDefaultValue(): void;
/**
* Executes the {@link BaseFormAssociatedElement._updateValidity | `_updateValidity()`} hook and then applies
* the {@link BaseFormAssociatedElement.invalid | `invalid`} attribute on the control and the associated styles
* if the element has completed the first update cycle or it has been interacted with by the user.
*/
protected _validate(message?: string): void;
/**
* Executes the component's validators and updates the internal validity state.
*/
protected _updateValidity(message?: string): void;
/**
* Sets the component's submission value and state.
*/
protected _setFormValue(value: FormValueType, state?: FormValueType): void;
/**
* Called by the browser when it associates/disassociates the component with/from a given form element.
* Receives the form element as a parameter.
*
* @remarks
* This is not implemented currently.
*/
protected formAssociatedCallback(form: HTMLFormElement): void;
/**
* Called whenever the component or a parent `fieldset` elements are disabled.
* Receives the current disabled state.
*/
protected formDisabledCallback(state: boolean): void;
/**
* Called when the form is reset.
* Resets the component value/checked state to the default one, internal state and validation.
*
* @remarks
* The default implementation calls {@link BaseFormAssociatedElement._restoreDefaultValue | `_restoreDefaultValue`}.
* If additional customization is needed, it is better to override that method instead of this callback.
*/
protected formResetCallback(): void;
/**
* Called when the browser attempts to automatically fill out the component.
*
* @remarks
* This is not implemented currently.
*/
protected formStateRestoreCallback(state: FormValueType, mode: FormRestoreMode): void;
/** Checks for validity of the control and emits the invalid event if it invalid. */
checkValidity(): boolean;
/** Checks for validity of the control and shows the browser message if it invalid. */
reportValidity(): boolean;
/**
* Sets a custom validation message for the control.
* As long as `message` is not empty, the control is considered invalid.
*/
setCustomValidity(message: string): void;
}
export declare class FormAssociatedElementInterface extends BaseFormAssociatedElement {
/** The initial value of the component. */
set defaultValue(value: unknown);
get defaultValue(): unknown;
}
export declare class FormAssociatedCheckboxElementInterface extends BaseFormAssociatedElement {
/** The initial checked state of the component. */
set defaultChecked(value: boolean);
get defaultChecked(): boolean;
}
export declare class FormRequiredInterface {
protected _required: boolean;
/**
* When set, makes the component a required field for validation.
* @attr
* @default false
*/
set required(value: boolean);
get required(): boolean;
}
export {};