import TerraElement, { type TerraFormControl } from '../../internal/terra-element.js'; import TerraIcon from '../icon/icon.component.js'; import type { CSSResultGroup } from 'lit'; /** * @summary A text input component with consistent styling across the design system. * @documentation https://terra-ui.netlify.app/components/input * @status stable * @since 1.0 * * @dependency terra-icon * * @slot prefix - Used to prepend content (like an icon) to the input. * @slot suffix - Used to append content (like an icon) to the input. When `clearable` or `resettable` is true, this slot is overridden. * @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 terra-input - Emitted when the input receives input. * @event terra-change - Emitted when an alteration to the control's value is committed by the user. * @event terra-focus - Emitted when the control gains focus. * @event terra-blur - Emitted when the control loses focus. * @event terra-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * @event terra-clear - Emitted when the clear button is activated. * * @csspart base - The component's base wrapper. * @csspart input - The internal input control. * @csspart prefix - The container for prefix content. * @csspart suffix - The container for suffix content. * @csspart clear-button - The clear button. * @csspart password-toggle-button - The password toggle button. * @csspart form-control-help-text - The help text's wrapper. * @csspart form-control-error-text - The error text's wrapper. */ export default class TerraInput extends TerraElement implements TerraFormControl { static styles: CSSResultGroup; static dependencies: { 'terra-icon': typeof TerraIcon; }; private readonly formControlController; private readonly hasSlotController; input: HTMLInputElement; hasFocus: boolean; private validationErrorMessage; private __numberInput; private __dateInput; title: string; type: 'date' | 'datetime-local' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url'; name: string; value: string; placeholder: string; size: 'small' | 'medium' | 'large'; filled: boolean; pill: boolean; disabled: boolean; readonly: boolean; required: boolean; autocomplete?: string; minlength?: number; maxlength?: number; min?: number | string; max?: number | string; step?: number | 'any'; pattern?: string; inputMode: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'; label: string; hideLabel: boolean; helpText: string; errorText: string; clearable: boolean; passwordToggle: boolean; passwordVisible: boolean; noSpinButtons: boolean; autofocus: boolean; enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'; spellcheck: boolean; /** The default value of the form control. Primarily used for resetting the form control. */ defaultValue: string; /** * When true, shows a reset icon in the suffix that clears the input value when clicked. * The input will be reset to its `defaultValue` (or empty string if no defaultValue is set). */ resettable: 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; /** Gets the validity state object */ get validity(): ValidityState; /** Gets the validation message */ get validationMessage(): string; /** * Gets or sets the current value as a `Date` object. Returns `null` if the value can't be converted. * This will use the native `` implementation and may result in an error. */ get valueAsDate(): Date | null; set valueAsDate(newValue: Date | null); /** Gets or sets the current value as a number. Returns `NaN` if the value can't be converted. */ get valueAsNumber(): number; set valueAsNumber(newValue: number); firstUpdated(): void; handleInput(): void; handleChange(): void; private handleInvalid; handleFocus(): void; handleBlur(): void; private handleKeyDown; private updateValidationErrorMessage; private handleReset; private handleClearClick; private handlePasswordToggle; handleDisabledChange(): void; handleStepChange(): void; handleValueChange(): Promise; /** 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. The value provided will be shown to the user when the form is submitted. To clear * the custom validation message, call this method with an empty string. */ setCustomValidity(message: string): void; focus(options?: FocusOptions): void; blur(): void; select(): void; setSelectionRange(selectionStart: number, selectionEnd: number, selectionDirection?: 'forward' | 'backward' | 'none'): void; /** Replaces a range of text with a new string. */ setRangeText(replacement: string, start?: number, end?: number, selectMode?: 'select' | 'start' | 'end' | 'preserve'): void; /** Displays the browser picker for an input element (only works if the browser supports it for the input type). */ showPicker(): void; /** Increments the value of a numeric input type by the value of the step attribute. */ stepUp(): void; /** Decrements the value of a numeric input type by the value of the step attribute. */ stepDown(): void; render(): import("lit-html").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { 'terra-input': TerraInput; } }