import type { CSSResultGroup } from 'lit'; import DSAErrorText from '../error-text/error-text'; import DSAVisuallyHidden from '../visually-hidden/visually-hidden'; import '../../internal/components/checkbox-box/checkbox-box'; import { ShoelaceElement } from '../../internal/shoelace-element'; import type { ShoelaceFormControl } from '../../internal/shoelace-element'; /** * @summary Checkboxes allow the user to toggle an option on or off. * @documentation https://dsa.service-public-autonomie.fr/latest/librairie-webcomponents/checkbox/case-a-cocher-checkbox/web-oi1eH6ls * * @dependency dsa-error-text * @dependency dsa-visually-hidden * * @slot - The checkbox's label. * * @event dsa-blur - Emitted when the checkbox loses focus. * @event dsa-change - Emitted when the checked state changes. * @event dsa-focus - Emitted when the checkbox gains focus. * @event dsa-input - Emitted when the checkbox receives input. * @event dsa-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * */ export default class DSACheckbox extends ShoelaceElement implements ShoelaceFormControl { static styles: CSSResultGroup; static dependencies: { 'dsa-error-text': typeof DSAErrorText; 'dsa-visually-hidden': typeof DSAVisuallyHidden; }; private readonly formControlController; private readonly hasSlotController; input: HTMLInputElement; private hasFocus; /** (deprecated) The use of this attribute will lead to a duplicated reading by screen readers. You can use the accessible-name attribute instead. */ title: string; /** The name of the checkbox, submitted as a name/value pair with form data. */ name: string; /** The current value of the checkbox, submitted as a name/value pair with form data. */ value: string; /** The checkbox's size. */ size: 'small' | 'medium' | 'large'; /** Disables the checkbox. */ parentDisabled: boolean; /** Disables the checkbox. */ disabled: boolean; /** Draws the checkbox in a checked state. */ checked: boolean; /** * Draws the checkbox in an indeterminate state. This is usually applied to checkboxes that represents a "select * all/none" behavior when associated checkboxes have a mix of checked and unchecked states. */ indeterminate: boolean; /** The default value of the form control. Primarily used for resetting the form control. */ defaultChecked: boolean; /** Disables the checkbox. */ parentReadonly: boolean; /** Sets the checkbox in readonly. */ readonly: boolean; /** Indicates whether the checkbox's should be in error state */ error: boolean; /** An error message that is shown when `error` is set to true. If there are several messages, must be a * string of messages separated by a pipe, e.g. "Error 1|Error 2|Error 3" */ errorMessage: string | string[]; /** * By default, form controls are associated with the nearest containing `
` element. This attribute allows you * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in * the same document or shadow root for this to work. */ form: string; /** Makes the checkbox a required field. */ required: boolean; /** (deprecated) The use of this attribute will lead to a duplicated reading by screen readers. You can use the accessible-name attribute instead. */ ariaLabel: string; /** Provides an accessible label for the checkbox element (used by dsa-table-row and dsa-table-header-row) */ accessibleName: string; /** Gets the validity state object */ get validity(): ValidityState; /** Gets the validation message */ get validationMessage(): string; connectedCallback(): void; firstUpdated(): void; private handleClick; private handleBlur; private handleInput; private handleInvalid; private handleFocus; handleDeactivatedChange(): void; handleStateChange(): void; handleErrorChange(): void; /** Simulates a click on the checkbox. */ click(): void; /** Sets focus on the checkbox. */ focus(options?: FocusOptions): void; /** Removes focus from the checkbox. */ blur(): void; /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */ checkValidity(): boolean; /** Gets the associated form, if one exists. */ getForm(): HTMLFormElement | null; /** Checks for validity and shows the browser's validation message if the control is invalid. */ reportValidity(): boolean; /** * Sets a custom validation message. The value provided will be shown to the user when the form is submitted. To clear * the custom validation message, call this method with an empty string. */ setCustomValidity(message: string): void; render(): import("lit").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { 'dsa-checkbox': DSACheckbox; } }