import ShoelaceElement from '../../internal/shoelace-element.js'; import type { CSSResultGroup } from 'lit'; import type { ShoelaceFormControl } from '../../internal/shoelace-element.js'; /** * @summary Switches allow the user to toggle an option on or off. * @documentation https://shoelace.style/components/switch * @status stable * @since 2.0 * * @slot - The switch's label. * * @event sl-blur - Emitted when the control loses focus. * @event sl-change - Emitted when the control's checked state changes. * @event sl-input - Emitted when the control receives input. * @event sl-focus - Emitted when the control gains focus. * @event sl-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * * @csspart base - The component's base wrapper. * @csspart control - The control that houses the switch's thumb. * @csspart thumb - The switch's thumb. * @csspart label - The switch's label. * * @cssproperty --width - The width of the switch. * @cssproperty --height - The height of the switch. * @cssproperty --thumb-size - The size of the thumb. */ export default class SlSwitch extends ShoelaceElement implements ShoelaceFormControl { static styles: CSSResultGroup; private readonly formControlController; input: HTMLInputElement; private hasFocus; title: string; /** 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; /** 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 `