/* * Copyright (c) 2025, Salesforce, Inc. * All rights reserved. * For full license text, see the LICENSE.txt file */ /** * The `lightning/input` component creates an HTML element. * @see {@link https://developer.salesforce.com/docs/component-library/bundle/lightning-input/documentation|Lightning Input Documentation} */ declare module "lightning/input" { import { LightningElement } from "lwc"; /** * Creates an HTML element. * Represents interactive controls that accept user input depending on the type attribute. */ export default class LightningInput extends LightningElement { // Text and label properties /** * Text that is displayed when the field is empty, to prompt the user for a valid entry. * Use this attribute with date, email, number, password, search, tel, text, time, and url input types only. */ placeholder: string; /** * Specifies the name of an input element. */ name: string; /** * Text label for the input. */ label: string; // Validation message properties /** * Error message to be displayed when a bad input is detected. * The badInput error can be returned for invalid input for any input type. */ messageWhenBadInput: string; /** * Error message to be displayed when a pattern mismatch is detected. * The patternMismatch error can be returned when you specify a pattern for email, password, search, tel, text, or url input types. */ messageWhenPatternMismatch: string; /** * Error message to be displayed when a range overflow is detected. * The rangeOverflow error can be returned when you specify a max value for number or range input types. */ messageWhenRangeOverflow: string; /** * Error message to be displayed when a range underflow is detected. * The rangeUnderflow error can be returned when you specify a min value for number or range input types. */ messageWhenRangeUnderflow: string; /** * Error message to be displayed when a step mismatch is detected. * The stepMismatch error can be returned when you specify a step value for number and range input types. */ messageWhenStepMismatch: string; /** * Error message to be displayed when the value is too short. * The tooShort error can be returned when you specify a min-length value for email, password, search, tel, text, and url input types. */ messageWhenTooShort: string; /** * Error message to be displayed when the value is too long. * The tooLong error can be returned when you specify a max-length value for email, password, search, tel, text, and url input types. */ messageWhenTooLong: string; /** * Error message to be displayed when a type mismatch is detected. * The typeMismatch error can be returned for the email and url input types. */ messageWhenTypeMismatch: string; /** * Error message to be displayed when the value is missing. * The valueMissing error can be returned when you specify the required attribute for any input type. */ messageWhenValueMissing: string; // Toggle-specific messages /** * Text shown for the active state of a toggle. The default is "Active". */ messageToggleActive: string; /** * Text shown for the inactive state of a toggle. The default is "Inactive". */ messageToggleInactive: string; // Accessibility properties /** * Describes the input to assistive technologies. */ ariaLabel: string; /** * Specifies the value of the aria-haspopup attribute */ ariaHasPopup: string; /** * Specifies the value of the aria-keyshortcuts attribute */ ariaKeyShortcuts: string; /** * Specifies the value of the aria-disabled attribute */ // @ts-expect-error: Property 'ariaDisabled' in type 'LightningInput' is not assignable to the same property in base type 'LightningShadowBaseClass'. // Type 'boolean' is not assignable to type 'string'. ariaDisabled: boolean; /** * Specifies the value of the aria-roledescription attribute */ ariaRoleDescription: string; /** * Specifies the value of the aria-expanded attribute, only valid on type simple */ ariaExpanded: string | null; /** * Specifies the value of the aria-autocomplete, only valid on type simple */ ariaAutoComplete: string | null; /** * A Boolean value for aria-invalid. */ // @ts-expect-errorProperty 'ariaInvalid' in type 'LightningInput' is not assignable to the same property in base type 'LightningElement'. // Type 'boolean' is not assignable to type 'string'. ariaInvalid: boolean; /** * A space-separated list of element IDs whose presence or content is controlled by the input. */ ariaControls: string | null; /** * A space-separated list of IDs of elements that provide details for the input. */ ariaDetails: string | null; /** * A space-separated list of element IDs that provide labels for the input. */ ariaLabelledBy: string | null; /** * A space-separated list of element IDs that provide descriptive labels for the input. */ ariaDescribedBy: string | null; /** * A space-separated list of element IDs that provide descriptive error message for input. */ ariaErrorMessage: string | null; // Date/time specific aria properties /** * Describes the date input to assistive technologies when type='datetime'. * On mobile devices, this label is merged with aria-label and time-aria-label to describe the native date time input. */ dateAriaLabel: string; /** * Describes the time input to assistive technologies when type='datetime'. * On mobile devices, this label is merged with aria-label and date-aria-label to describe the native date time input. */ timeAriaLabel: string; /** * A space-separated list of element IDs whose presence or content is controlled by the * date input when type='datetime'. On mobile devices, this is merged with aria-controls * and time-aria-controls to describe the native date time input. */ dateAriaControls: string | undefined; /** * A space-separated list of element IDs whose presence or content is controlled by the * time input when type='datetime'. On mobile devices, this is merged with aria-controls * and date-aria-controls to describe the native date time input. */ timeAriaControls: string | undefined; /** * A space-separated list of IDs of elements that provide details of the * date input when type='datetime'. */ dateAriaDetails: string | undefined; /** * A space-separated list of IDs of elements that provide details of the * time input when type='datetime'. */ timeAriaDetails: string | undefined; /** * A space-separated list of element IDs that provide error messages for the date input when type='datetime'. */ dateAriaErrorMessage: string | undefined; /** * A space-separated list of element IDs that provide error messages for the time input when type='datetime'. */ timeAriaErrorMessage: string | undefined; /** * A space-separated list of element IDs that provide labels for the date input when type='datetime'. * On mobile devices, this is merged with aria-labelled-by and time-aria-labelled-by to describe * the native date time input. */ dateAriaLabelledBy: string | undefined; /** * A space-separated list of element IDs that provide labels for the time input when type='datetime'. * On mobile devices, this is merged with aria-labelled-by and date-aria-labelled-by to describe * the native date time input. */ timeAriaLabelledBy: string | undefined; /** * A space-separated list of element IDs that provide descriptive labels for the date input when * type='datetime'. On mobile devices, this is merged with aria-described-by and time-aria-described-by * to describe the native date time input. */ dateAriaDescribedBy: string | undefined; /** * A space-separated list of element IDs that provide descriptive labels for the time input when * type='datetime'. On mobile devices, this is merged with aria-described-by and date-aria-described-by * to describe the native date time input. */ timeAriaDescribedBy: string | undefined; // Input behavior properties /** * Controls auto-filling of the field. Use this attribute with * email, search, tel, text, and url input types only. Set the attribute to pass * through autocomplete values to be interpreted by the browser. */ autocomplete: string | undefined; /** * The type of the input. Valid values are checkbox, checkbox-button, * color, date, datetime, time, email, file, password, range, search, * tel, url, number, and toggle. This value defaults to text. */ type: | "checkbox" | "checkbox-button" | "color" | "date" | "datetime" | "time" | "email" | "file" | "password" | "range" | "search" | "tel" | "url" | "number" | "toggle"; /** * For the search type only. If present, a spinner is displayed to indicate that data is loading. */ isLoading: boolean; /** * Specifies the regular expression that the input's value is checked against. * This attribute is supported for email, password, search, tel, text, and url types. */ pattern: string; /** * The maximum number of characters allowed in the field. * Use this attribute with email, password, search, tel, text, and url input types only. */ maxLength: number | undefined; /** * The minimum number of characters allowed in the field. * Use this attribute with email, password, search, tel, text, and url input types only. */ minLength: number | undefined; /** * Specifies the types of files that the server accepts. Use this attribute with file input type only. */ accept: string | undefined; /** * The maximum acceptable value for the input. Use this attribute with number, * range, date, time, and datetime input types only. For number and range type, the max value is a * decimal number. For the date, time, and datetime types, the max value must use a valid string for the type. */ max: string | number | undefined; /** * The minimum acceptable value for the input. Use this attribute with number, * range, date, time, and datetime input types only. For number and range types, the min value * is a decimal number. For the date, time, and datetime types, the min value must use a valid string for the type. */ min: string | number | undefined; /** * Granularity of the value, specified as a positive floating point number. * Use this attribute with number and range input types only. * Use 'any' when granularity is not a concern. This value defaults to 1. */ step: string | number | undefined; /** * If present, the checkbox is selected. */ checked: boolean; /** * Specifies that a user can enter more than one value. Use this attribute with file and email input types only. */ multiple: boolean; /** * Specifies the value of an input element. */ value: string; /** * If present, the input field is disabled and users cannot interact with it. */ disabled: boolean; /** * If present, the input field is read-only and cannot be edited by users. */ readOnly: boolean; /** * If present, the input field must be filled out before the form is submitted. */ required: boolean; // Display and formatting properties /** * The variant changes the appearance of an input field. */ variant: string; /** * The display style of the date when type='date' or type='datetime'. Valid values are * short, medium (default), and long. The format of each style is specific to the locale. * On mobile devices this attribute has no effect. * @default medium */ dateStyle: "short" | "medium" | "long"; /** * The display style of the time when type='time' or type='datetime'. Valid values are * short (default), medium, and long. Currently, medium and long styles look the same. * On mobile devices this attribute has no effect. * @default short */ timeStyle: "short" | "medium" | "long"; /** * Specifies the time zone used when type='datetime' only. This value defaults to the user's Salesforce time zone setting. */ timezone: string; /** * String value with the formatter to be used for number input. Valid values include * decimal, percent, percent-fixed, and currency. */ formatter: "decimal" | "percent" | "percent-fixed" | "currency"; /** * Reserved for internal use. */ formatFractionDigits: number; /** * Help text detailing the purpose and function of the input. * This attribute isn't supported for file, toggle, and checkbox-button types. */ fieldLevelHelp: string | undefined; /** * Specifies a shortcut key to activate or focus an element. */ accessKey: string; // Date/time access keys /** * Sets a key that can be used to access the date picker when you use the datetime type. */ dateAccessKey: string; /** * Sets a key that can be used to access the time picker when you use the datetime type. */ timeAccessKey: string; // Selection properties /** * Specifies the index of the first character to select in the input element. * This attribute is supported only for text type. * Use with selection-end to programmatically set or read the position of * selected text. */ selectionStart: number | null | undefined; /** * Specifies the index of the last character to select in the input element. * This attribute is supported only for text type. * Use with selection-start to programmatically set or read the position of * selected text. */ selectionEnd: number | null | undefined; // Role property /** * The role set on lightning-primitive-input-simple to allow external developers to have a type="text" * and role="combobox" if lightning-combobox does not meet their requirements. */ role: string | null; // File and validity properties /** * A FileList that contains selected files. Use this attribute with the file input type only. */ files: FileList | null; /** * Represents the validity states that an element can be in, with respect to constraint validation. */ validity: ValidityState; // Methods /** * Checks if the input is valid. */ checkValidity(): boolean; /** * Sets a custom error message to be displayed when a form is submitted. */ setCustomValidity(message: string): void; /** * Displays the error messages and returns false if the input is invalid. * If the input is valid, reportValidity() clears displayed error messages and returns true. */ reportValidity(): boolean; /** * Displays error messages on invalid fields. * An invalid field fails at least one constraint validation and returns false when checkValidity() is called. */ showHelpMessageIfInvalid(): void; /** * Sets focus on the input element. */ focus(): void; /** * Removes keyboard focus from the input element. */ blur(): void; } }