/** * Base class for auro-input component that provides core input functionality. * @event input - Event fires when the value of an `auro-input` has been changed. * @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` value has changed. */ export default class BaseInput extends AuroElement { static get shadowRootOptions(): { delegatesFocus: boolean; clonable?: boolean; customElementRegistry?: CustomElementRegistry; mode: ShadowRootMode; serializable?: boolean; slotAssignment?: SlotAssignmentMode; }; static get properties(): { /** * The value for the role attribute. */ a11yRole: { type: StringConstructor; reflect: boolean; }; /** * The value for the aria-controls attribute. */ a11yControls: { type: StringConstructor; reflect: boolean; }; /** * The value for the aria-expanded attribute. */ a11yExpanded: { type: BooleanConstructor; reflect: boolean; }; /** * The value for the aria-activedescendant attribute. * Points to the ID of the currently active/highlighted option in a listbox. */ a11yActivedescendant: { type: StringConstructor; reflect: boolean; }; /** * If set, the label will remain fixed in the active position. */ activeLabel: { type: BooleanConstructor; reflect: boolean; }; /** * Defines whether the component will be on lighter or darker backgrounds. * @type {'default' | 'inverse'} * @default 'default' */ appearance: "default" | "inverse"; /** * An enumerated attribute that controls whether and how text input is automatically capitalized as it is entered/edited by the user. [off/none, on/sentences, words, characters]. */ autocapitalize: { type: StringConstructor; reflect: boolean; }; /** * An enumerated attribute that defines what the user agent can suggest for autofill. At this time, only `autocomplete="off"` is supported. */ autocomplete: { type: StringConstructor; reflect: boolean; }; /** * When set to `off`, stops iOS from auto-correcting words when typed into a text box. */ autocorrect: { type: StringConstructor; reflect: boolean; }; /** * Custom help text message for email type validity. */ customValidityTypeEmail: { type: StringConstructor; }; /** * If set, disables the input. */ disabled: { type: BooleanConstructor; reflect: boolean; }; /** * If defined, the display value slot content will only mask the HTML5 input element. The input's label will not be masked. */ dvInputOnly: { type: BooleanConstructor; reflect: boolean; }; /** * When defined, sets persistent validity to `customError` and sets `setCustomValidity` = attribute value. */ error: { type: StringConstructor; reflect: boolean; }; /** * Contains the help text message for the current validity error. */ errorMessage: { type: StringConstructor; }; /** * Specifies the input mask format. */ format: { type: StringConstructor; reflect: boolean; }; /** * Flag to indicate if the input currently has focus. */ hasFocus: { type: BooleanConstructor; reflect: boolean; attribute: boolean; }; /** * Flag to indicate if the input currently has value. */ hasValue: { type: BooleanConstructor; reflect: boolean; attribute: boolean; }; /** * If set, the label will be hidden visually but still accessible to assistive technologies. * @private */ hideLabelVisually: { type: BooleanConstructor; reflect: boolean; }; /** * If set, will render an icon inside the input to the left of the value. Support is limited to auro-input instances with credit card format. */ icon: { type: BooleanConstructor; reflect: boolean; }; /** * The id global attribute defines an identifier (ID) which must be unique in the whole document. */ id: { type: StringConstructor; }; /** * The id for input node. * @private */ inputId: { type: StringConstructor; reflect: boolean; attribute: boolean; }; /** Exposes inputmode attribute for input. */ inputmode: { type: StringConstructor; reflect: boolean; }; /** * Defines the language of an element. */ lang: { type: StringConstructor; reflect: boolean; }; /** * The maximum value allowed. This only applies for inputs with a type of `number` and all date formats. */ max: { type: StringConstructor; }; /** * The maximum number of characters the user can enter into the text input. This must be an integer value `0` or higher. * **Note**: This attribute is not intended to be used with a `type` or `format` that already has a defined length, such as credit-cards, dates or phone numbers. */ maxLength: { type: NumberConstructor; reflect: boolean; }; /** * The minimum value allowed. This only applies for inputs with a type of `number` and all date formats. */ min: { type: StringConstructor; }; /** * The minimum number of characters the user can enter into the text input. This must be a non-negative integer value smaller than or equal to the value specified by `maxlength`. */ minLength: { type: NumberConstructor; reflect: boolean; }; /** * Populates the `name` attribute on the input. */ name: { type: StringConstructor; reflect: boolean; }; /** * Sets styles for nested operation - removes borders, hides help + error text, and * hides accents. */ nested: { type: BooleanConstructor; reflect: boolean; }; /** * If set, disables auto-validation on blur. */ noValidate: { type: BooleanConstructor; reflect: boolean; }; /** * DEPRECATED - use `appearance="inverse"` instead. */ onDark: { type: BooleanConstructor; reflect: boolean; }; /** * Specifies a regular expression the form control's value should match. */ pattern: { type: StringConstructor; reflect: boolean; }; /** * Define custom placeholder text. */ placeholder: { type: StringConstructor; reflect: boolean; }; /** * Makes the input read-only, but can be set programmatically. */ readonly: { type: BooleanConstructor; reflect: boolean; }; /** * Populates the `required` attribute on the input. Used for client-side validation. */ required: { type: BooleanConstructor; reflect: boolean; }; /** * Sets a custom help text message to display for all validityStates. */ setCustomValidity: { type: StringConstructor; }; /** * Custom help text message to display when validity = `badInput`. */ setCustomValidityBadInput: { type: StringConstructor; }; /** * Custom help text message to display when validity = `customError`. */ setCustomValidityCustomError: { type: StringConstructor; }; /** * Custom help text message to display for the declared element `type` and type validity fails. */ setCustomValidityForType: { type: StringConstructor; }; /** * Custom help text message to display when validity = `rangeOverflow`. */ setCustomValidityRangeOverflow: { type: StringConstructor; }; /** * Custom help text message to display when validity = `rangeUnderflow`. */ setCustomValidityRangeUnderflow: { type: StringConstructor; }; /** * Custom help text message to display when validity = `tooLong`. */ setCustomValidityTooLong: { type: StringConstructor; }; /** * Custom help text message to display when validity = `tooShort`. */ setCustomValidityTooShort: { type: StringConstructor; }; /** * Custom help text message to display when validity = `valueMissing`. */ setCustomValidityValueMissing: { type: StringConstructor; }; /** * @ignore */ showPassword: { state: boolean; }; /** * Simple makes the input render without a border. */ simple: { type: BooleanConstructor; reflect: boolean; }; /** * An enumerated attribute defines whether the element may be checked for spelling errors. [true, false]. When set to `false` the attribute `autocorrect` is set to `off` and `autocapitalize` is set to `none`. */ spellcheck: { type: StringConstructor; reflect: boolean; }; /** * Indicates whether the input is in a dirty state (has been interacted with). * @private */ touched: { type: BooleanConstructor; reflect: boolean; attribute: boolean; }; /** * Populates the `type` attribute on the input. * @type {'text' | 'password' | 'email' | 'credit-card' | 'tel' | 'number'} * @default 'text' */ type: "text" | "password" | "email" | "credit-card" | "tel" | "number"; /** * Sets validation mode to re-eval with each input. */ validateOnInput: { type: BooleanConstructor; }; /** * Specifies the `validityState` this element is in. */ validity: { type: StringConstructor; reflect: boolean; }; /** * Populates the `value` attribute on the input. Can also be read to retrieve the current value of the input. */ value: { type: StringConstructor; }; layout: { type: StringConstructor; attribute: string; reflect: boolean; }; }; /** * Internal Defaults. * @private * @returns {void} */ private _initializeDefaults; activeLabel: boolean; appearance: string; icon: boolean; disabled: boolean; dvInputOnly: boolean; hideLabelVisually: boolean; max: any; maxLength: any; min: any; minLength: any; noValidate: boolean; onDark: boolean; required: boolean; setCustomValidityForType: string; /** * @private */ private shape; /** * @private */ private size; touched: boolean; util: AuroInputUtilities; validation: AuroFormValidation; inputIconName: any; showPassword: any; validationCCLength: number; hasValue: boolean; label: string; allowedInputTypes: string[]; /** * Credit Card is not included as this caused cursor placement issues. * The Safari issue. */ setSelectionInputTypes: string[]; dateFormatMap: { 'mm/dd/yyyy': string; 'dd/mm/yyyy': string; 'yyyy/mm/dd': string; 'yyyy/dd/mm': string; 'mm/yy': string; 'yy/mm': string; 'mm/yyyy': string; 'yyyy/mm': string; yy: string; yyyy: string; mm: string; dd: string; 'dd/mm': string; 'mm/dd': string; }; uniqueId: string; firstUpdated(): void; wrapperElement: Element; inputElement: HTMLInputElement; labelElement: HTMLLabelElement; inputId: string; format: any; ValidityMessageOverride: any; /** * Patches the input element to dispatch an 'input' event whenever its value is set programmatically. * This ensures that changes to the input's value are consistently communicated, even if not triggered by user input. * * @param {HTMLInputElement} input - The input element to patch. * @returns {void} * @private */ private patchInputEvent; /** * @private * @returns {void} Sets the default help text for the input. */ private setCustomHelpTextMessage; /** * LitElement lifecycle method. Called after the DOM has been updated. * @param {Map} changedProperties - Keys are the names of changed properties, values are the corresponding previous values. * @returns {void} */ updated(changedProperties: Map): void; skipNextProgrammaticInputEvent: boolean; /** * @private * @returns {void} Notify validity state changed via event. */ private notifyValidityChange; /** * Sets up IMasks and logic based on auto-formatting requirements. * @private * @returns {void} */ private configureAutoFormatting; maskInstance: import("imask").InputMask; value: string; formattedDate: any; comparisonDate: any; /** * @private * @returns {string} */ private definePattern; /** * Required to convert SVG icons from data to HTML string. * @private * @param {string} icon HTML string for requested icon. * @returns {object} Appended HTML for SVG. */ private getIconAsHtml; /** * Sends event notifying that the input has changed it's value. * @private * @returns {void} */ private notifyValueChanged; /** * Handles clicking on the auro-input anywhere outside of the HTML5 input and still moving focus in. * @private * @return {void} */ private handleClick; /** * Function to set element focus. * @return {void} */ focus(): void; /** * Handles event of clearing input content by clicking the X icon. * @private * @return {void} */ private handleClickClear; /** * @param {Event} event - The input event. * @private * @returns {void} */ private handleInput; /** * Function to support @focusin event. * @private * @return {void} */ private handleFocusin; hasFocus: boolean; /** * Function to support @focusout event. * @private * @return {void} */ private handleFocusout; /** * Function to support @blur event. * @private * @return {void} */ private handleBlur; /** * Returns focused element, even if it's in the shadow DOM. * @private * @param {Object} root - Element to check for focus. * @returns {Object} */ private getActiveElement; /** * Sets the active descendant element for accessibility. * Uses ariaActiveDescendantElement to cross shadow DOM boundaries. * This function is used in components that contain `auro-input` to set the active descendant. * @private * @param {HTMLElement|null} element - The element to set as the active descendant, or null to clear. * @returns {void} */ private setActiveDescendant; /** * Validates value. * @param {boolean} [force=false] - Whether to force validation. */ validate(force?: boolean): void; /** * Resets component to initial state, including resetting the touched state and validity. * @returns {void} */ reset(): void; /** * Clears the input value. */ clear(): void; /** * Sets configuration data used elsewhere based on the `type` attribute. * @private * @returns {void} */ private configureDataForType; lengthForType: any; inputmode: any; /** * Validates against list of supported this.allowedInputTypes; return type=text if invalid request. * @private * @param {string} type Value entered into component prop. * @returns {string} Iterates over allowed types array. */ private getInputType; /** * Determines default help text string. * @private * @returns {string} Evaluates pre-determined help text. */ private getHelpText; /** * Function to support show-password feature. * @private * @returns {void} */ private handleClickShowPassword; /** * Support placeholder text. * @private * @returns {void} */ private get placeholderStr(); /** * Defines placement of input icon based on type, used with classMap. * @private * @returns {boolean} */ private defineInputIcon; /** * Defines padding of input label based on type, used with classMap. * @private * @returns {boolean} */ private defineLabelPadding; /** * Function to support credit-card feature type. * @private * @returns {void} */ private processCreditCard; errorMessage: any; /** * Function to support credit-card feature type. * @private * @returns {object} JSON with data for credit card formatting. */ private matchInputValueToCreditCard; } import { AuroElement } from '../../layoutElement/src/auroElement.js'; import { AuroInputUtilities } from "./utilities.js"; import AuroFormValidation from '@aurodesignsystem/form-validation';