import type { CSSResultGroup } from 'lit'; import DSAIcon from '../icon/icon'; import { ShoelaceElement } from '../../internal/shoelace-element'; import type { ShoelaceFormControl } from '../../internal/shoelace-element'; /** * @summary Switches allow the user to toggle an option on or off. * @documentation https://dsa.service-public-autonomie.fr/latest/librairie-webcomponents/switch-interrupteur/web-QfQYREPu * * @dependency dsa-icon * * @slot - The switch's label. * * @event dsa-blur - Emitted when the control loses focus. * @event dsa-change - Emitted when the control's checked state changes. * @event dsa-input - Emitted when the control receives input. * @event dsa-focus - Emitted when the control gains focus. * @event dsa-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. */ export default class DSASwitch extends ShoelaceElement implements ShoelaceFormControl { static styles: CSSResultGroup; static dependencies: { 'dsa-icon': typeof DSAIcon; }; private readonly formControlController; private readonly localize; input: HTMLInputElement; private hasFocus; /** The name of the switch, submitted as a name/value pair with form data. */ name: string; /** The current value of the switch, submitted as a name/value pair with form data. */ value: string; /** The switch's size. */ size: 'small' | 'medium' | 'large'; /** Disables the switch. */ disabled: boolean; /** Sets the switch in readonly. */ readonly: boolean; /** Draws the switch in a checked state. */ checked: boolean; /** The default value of the form control. Primarily used for resetting the form control. */ defaultChecked: boolean; /** * 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 switch a required field. */ required: boolean; /** State ON text equivalent, to make understanding the state of the switch easier for users with visual or cognitive disabilities, */ labelOn: string; /** (Deprecated) Not working on Angular */ onLabel: string; /** State OFF text equivalent, to make understanding the state of the switch easier for users with visual or cognitive disabilities, */ labelOff: string; /** (Deprecated) */ offLabel: string; /** Gets the validity state object */ get validity(): ValidityState; /** Gets the validation message */ get validationMessage(): string; firstUpdated(): void; private handleBlur; private handleInput; private handleInvalid; private handleClick; private handleFocus; private handleKeyDown; handleCheckedChange(): void; handleDisabledChange(): void; /** Simulates a click on the switch. */ click(): void; /** Sets focus on the switch. */ focus(options?: FocusOptions): void; /** Removes focus from the switch. */ 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. Pass an empty string to restore validity. */ setCustomValidity(message: string): void; render(): import("lit").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { 'dsa-switch': DSASwitch; } }