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 `