import ShoelaceElement from '../../internal/shoelace-element.js'; import SlIcon from '../icon/icon.component.js'; import type { CSSResultGroup } from 'lit'; import type { ShoelaceFormControl } from '../../internal/shoelace-element.js'; /** * @summary Inputs collect data from the user. * @documentation https://shoelace.style/components/input * @status stable * @since 2.0 * * @dependency sl-icon * * @slot label - The input's label. Alternatively, you can use the `label` attribute. * @slot prefix - Used to prepend a presentational icon or similar element to the input. * @slot suffix - Used to append a presentational icon or similar element to the input. * @slot clear-icon - An icon to use in lieu of the default clear icon. * @slot show-password-icon - An icon to use in lieu of the default show password icon. * @slot hide-password-icon - An icon to use in lieu of the default hide password icon. * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute. * * @event sl-blur - Emitted when the control loses focus. * @event sl-change - Emitted when an alteration to the control's value is committed by the user. * @event sl-clear - Emitted when the clear button is activated. * @event sl-focus - Emitted when the control gains focus. * @event sl-input - Emitted when the control receives input. * @event sl-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * * @csspart form-control - The form control that wraps the label, input, and help text. * @csspart form-control-label - The label's wrapper. * @csspart form-control-input - The input's wrapper. * @csspart form-control-help-text - The help text's wrapper. * @csspart base - The component's base wrapper. * @csspart input - The internal `` control. * @csspart prefix - The container that wraps the prefix. * @csspart clear-button - The clear button. * @csspart password-toggle-button - The password toggle button. * @csspart suffix - The container that wraps the suffix. */ export default class SlInput extends ShoelaceElement implements ShoelaceFormControl { static styles: CSSResultGroup; static dependencies: { 'sl-icon': typeof SlIcon; }; private readonly formControlController; private readonly hasSlotController; private readonly localize; input: HTMLInputElement; private hasFocus; title: string; private __numberInput; private __dateInput; /** * The type of input. Works the same as a native `` element, but only a subset of types are supported. Defaults * to `text`. */ type: 'date' | 'datetime-local' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url'; /** The name of the input, submitted as a name/value pair with form data. */ name: string; /** The current value of the input, submitted as a name/value pair with form data. */ value: string; /** The default value of the form control. Primarily used for resetting the form control. */ defaultValue: string; /** The input's size. */ size: 'small' | 'medium' | 'large'; /** Draws a filled input. */ filled: boolean; /** Draws a pill-style input with rounded edges. */ pill: boolean; /** The input's label. If you need to display HTML, use the `label` slot instead. */ label: string; /** The input's help text. If you need to display HTML, use the `help-text` slot instead. */ helpText: string; /** Adds a clear button when the input is not empty. */ clearable: boolean; /** Disables the input. */ disabled: boolean; /** Placeholder text to show as a hint when the input is empty. */ placeholder: string; /** Makes the input readonly. */ readonly: boolean; /** Adds a button to toggle the password's visibility. Only applies to password types. */ passwordToggle: boolean; /** Determines whether or not the password is currently visible. Only applies to password input types. */ passwordVisible: boolean; /** Hides the browser's built-in increment/decrement spin buttons for number inputs. */ noSpinButtons: boolean; /** * By default, form controls are associated with the nearest containing `