@material/web
Version:
Material web components
139 lines (138 loc) • 4.49 kB
TypeScript
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import '../../focus/md-focus-ring.js';
import '../../ripple/ripple.js';
import { LitElement, PropertyValues } from 'lit';
/**
* A checkbox component.
*/
export declare class Checkbox extends LitElement {
/** @nocollapse */
static shadowRootOptions: {
delegatesFocus: boolean;
mode: ShadowRootMode;
slotAssignment?: SlotAssignmentMode;
};
/** @nocollapse */
static readonly formAssociated = true;
/**
* Whether or not the checkbox is selected.
*/
checked: boolean;
/**
* Whether or not the checkbox is disabled.
*/
disabled: boolean;
/**
* Whether or not the checkbox is indeterminate.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes
*/
indeterminate: boolean;
/**
* When true, require the checkbox to be selected when participating in
* form submission.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation
*/
required: boolean;
/**
* The value of the checkbox that is submitted with a form when selected.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value
*/
value: string;
/**
* The HTML name to use in form submission.
*/
get name(): string;
set name(name: string);
/**
* The associated form element with which this element's value will submit.
*/
get form(): HTMLFormElement;
/**
* The labels this element is associated with.
*/
get labels(): NodeList;
/**
* Returns a ValidityState object that represents the validity states of the
* checkbox.
*
* Note that checkboxes will only set `valueMissing` if `required` and not
* checked.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation
*/
get validity(): ValidityState;
/**
* Returns the native validation error message.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
*/
get validationMessage(): string;
/**
* Returns whether an element will successfully validate based on forms
* validation rules and constraints.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
*/
get willValidate(): boolean;
private prevChecked;
private prevDisabled;
private prevIndeterminate;
private readonly input;
private hasCustomValidityError;
private readonly internals;
constructor();
/**
* Checks the checkbox's native validation and returns whether or not the
* element is valid.
*
* If invalid, this method will dispatch the `invalid` event.
*
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
*
* @return true if the checkbox is valid, or false if not.
*/
checkValidity(): boolean;
/**
* Checks the checkbox's native validation and returns whether or not the
* element is valid.
*
* If invalid, this method will dispatch the `invalid` event.
*
* The `validationMessage` is reported to the user by the browser. Use
* `setCustomValidity()` to customize the `validationMessage`.
*
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity
*
* @return true if the checkbox is valid, or false if not.
*/
reportValidity(): boolean;
/**
* Sets the checkbox's native validation error message. This is used to
* customize `validationMessage`.
*
* When the error is not an empty string, the checkbox is considered invalid
* and `validity.customError` will be true.
*
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
*
* @param error The error message to display.
*/
setCustomValidity(error: string): void;
protected update(changed: PropertyValues<Checkbox>): void;
protected render(): import("lit-html").TemplateResult<1>;
protected updated(): void;
private handleChange;
private syncValidity;
private getInput;
/** @private */
formResetCallback(): void;
/** @private */
formStateRestoreCallback(state: string): void;
}