UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1,454 lines • 52.9 kB
/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.5.0-next.4 */ import { h, Host } from "@stencil/core"; import { getElementDir, getSlotted, isPrimaryPointerButton, setRequestedIcon } from "../../utils/dom"; import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form"; import { connectInteractive, disconnectInteractive, updateHostInteraction } from "../../utils/interactive"; import { numberKeys } from "../../utils/key"; import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label"; import { componentLoaded, setComponentLoaded, setUpLoadableComponent } from "../../utils/loadable"; import { connectLocalized, defaultNumberingSystem, disconnectLocalized, numberStringFormatter } from "../../utils/locale"; import { BigDecimal, isValidNumber, parseNumberString, sanitizeNumberString } from "../../utils/number"; import { createObserver } from "../../utils/observers"; import { CSS_UTILITY } from "../../utils/resources"; import { connectMessages, disconnectMessages, setUpMessages, updateMessages } from "../../utils/t9n"; import { CSS, INPUT_TYPE_ICONS, SLOTS } from "./resources"; /** * @slot action - A slot for positioning a `calcite-button` next to the component. */ export class Input { constructor() { /** keep track of the rendered child type */ this.childElType = "input"; this.previousValueOrigin = "initial"; this.mutationObserver = createObserver("mutation", () => this.setDisabledAction()); this.userChangedValue = false; //-------------------------------------------------------------------------- // // Private Methods // //-------------------------------------------------------------------------- this.keyDownHandler = (event) => { if (this.readOnly || this.disabled) { return; } if (this.isClearable && event.key === "Escape") { this.clearInputValue(event); event.preventDefault(); } if (event.key === "Enter" && !event.defaultPrevented) { if (submitForm(this)) { event.preventDefault(); } } }; this.clearInputValue = (nativeEvent) => { this.setValue({ committing: true, nativeEvent, origin: "user", value: "" }); }; this.emitChangeIfUserModified = () => { if (this.previousValueOrigin === "user" && this.value !== this.previousEmittedValue) { this.calciteInputChange.emit(); this.setPreviousEmittedValue(this.value); } }; this.inputBlurHandler = () => { this.calciteInternalInputBlur.emit(); this.emitChangeIfUserModified(); }; this.clickHandler = (event) => { if (this.disabled) { return; } const slottedActionEl = getSlotted(this.el, "action"); if (event.target !== slottedActionEl) { this.setFocus(); } }; this.inputFocusHandler = () => { this.calciteInternalInputFocus.emit(); }; this.inputChangeHandler = () => { if (this.type === "file") { this.files = this.childEl.files; } }; this.inputInputHandler = (nativeEvent) => { if (this.disabled || this.readOnly) { return; } this.setValue({ nativeEvent, origin: "user", value: nativeEvent.target.value }); }; this.inputKeyDownHandler = (event) => { if (this.disabled || this.readOnly) { return; } if (event.key === "Enter") { this.emitChangeIfUserModified(); } }; this.inputNumberInputHandler = (nativeEvent) => { if (this.disabled || this.readOnly) { return; } const value = nativeEvent.target.value; numberStringFormatter.numberFormatOptions = { locale: this.effectiveLocale, numberingSystem: this.numberingSystem, useGrouping: this.groupSeparator }; const delocalizedValue = numberStringFormatter.delocalize(value); if (nativeEvent.inputType === "insertFromPaste") { if (!isValidNumber(delocalizedValue)) { nativeEvent.preventDefault(); } this.setValue({ nativeEvent, origin: "user", value: parseNumberString(delocalizedValue) }); this.childNumberEl.value = this.localizedValue; } else { this.setValue({ nativeEvent, origin: "user", value: delocalizedValue }); } }; this.inputNumberKeyDownHandler = (event) => { if (this.type !== "number" || this.disabled || this.readOnly) { return; } if (event.key === "ArrowUp") { /* prevent default behavior of moving cursor to the beginning of the input when holding down ArrowUp */ event.preventDefault(); this.nudgeNumberValue("up", event); return; } if (event.key === "ArrowDown") { this.nudgeNumberValue("down", event); return; } const supportedKeys = [ ...numberKeys, "ArrowLeft", "ArrowRight", "Backspace", "Delete", "Enter", "Escape", "Tab" ]; if (event.altKey || event.ctrlKey || event.metaKey) { return; } const isShiftTabEvent = event.shiftKey && event.key === "Tab"; if (supportedKeys.includes(event.key) && (!event.shiftKey || isShiftTabEvent)) { if (event.key === "Enter") { this.emitChangeIfUserModified(); } return; } numberStringFormatter.numberFormatOptions = { locale: this.effectiveLocale, numberingSystem: this.numberingSystem, useGrouping: this.groupSeparator }; if (event.key === numberStringFormatter.decimal) { if (!this.value && !this.childNumberEl.value) { return; } if (this.value && this.childNumberEl.value.indexOf(numberStringFormatter.decimal) === -1) { return; } } if (/[eE]/.test(event.key)) { if (!this.value && !this.childNumberEl.value) { return; } if (this.value && !/[eE]/.test(this.childNumberEl.value)) { return; } } if (event.key === "-") { if (!this.value && !this.childNumberEl.value) { return; } if (this.value && this.childNumberEl.value.split("-").length <= 2) { return; } } event.preventDefault(); }; this.nudgeNumberValue = (direction, nativeEvent) => { if ((nativeEvent instanceof KeyboardEvent && nativeEvent.repeat) || this.type !== "number") { return; } const inputMax = this.maxString ? parseFloat(this.maxString) : null; const inputMin = this.minString ? parseFloat(this.minString) : null; const valueNudgeDelayInMs = 150; this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent); if (this.nudgeNumberValueIntervalId) { window.clearInterval(this.nudgeNumberValueIntervalId); } let firstValueNudge = true; this.nudgeNumberValueIntervalId = window.setInterval(() => { if (firstValueNudge) { firstValueNudge = false; return; } this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent); }, valueNudgeDelayInMs); }; this.numberButtonPointerUpAndOutHandler = () => { window.clearInterval(this.nudgeNumberValueIntervalId); }; this.numberButtonPointerDownHandler = (event) => { if (!isPrimaryPointerButton(event)) { return; } event.preventDefault(); const direction = event.target.dataset.adjustment; if (!this.disabled) { this.nudgeNumberValue(direction, event); } }; this.hiddenInputChangeHandler = (event) => { if (event.target.name === this.name) { this.setValue({ value: event.target.value, origin: "direct" }); } event.stopPropagation(); }; this.setChildElRef = (el) => { this.childEl = el; }; this.setChildNumberElRef = (el) => { this.childNumberEl = el; }; this.setInputValue = (newInputValue) => { if (this.type === "text" && !this.childEl) { return; } if (this.type === "number" && !this.childNumberEl) { return; } this[`child${this.type === "number" ? "Number" : ""}El`].value = newInputValue; }; this.setPreviousEmittedValue = (value) => { this.previousEmittedValue = this.normalizeValue(value); }; this.setPreviousValue = (value) => { this.previousValue = this.normalizeValue(value); }; this.setValue = ({ committing = false, nativeEvent, origin, previousValue, value }) => { this.setPreviousValue(previousValue ?? this.value); this.previousValueOrigin = origin; if (this.type === "number") { numberStringFormatter.numberFormatOptions = { locale: this.effectiveLocale, numberingSystem: this.numberingSystem, useGrouping: this.groupSeparator, signDisplay: "never" }; const sanitizedValue = sanitizeNumberString( // no need to delocalize a string that ia already in latn numerals (this.numberingSystem && this.numberingSystem !== "latn") || defaultNumberingSystem !== "latn" ? numberStringFormatter.delocalize(value) : value); const newValue = value && !sanitizedValue ? isValidNumber(this.previousValue) ? this.previousValue : "" : sanitizedValue; const newLocalizedValue = numberStringFormatter.localize(newValue); this.localizedValue = newLocalizedValue; this.userChangedValue = origin === "user" && this.value !== newValue; // don't sanitize the start of negative/decimal numbers, but // don't set value to an invalid number this.value = ["-", "."].includes(newValue) ? "" : newValue; } else { this.userChangedValue = origin === "user" && this.value !== value; this.value = value; } if (origin === "direct") { this.setInputValue(value); this.previousEmittedValue = value; } if (nativeEvent) { const calciteInputInputEvent = this.calciteInputInput.emit(); if (calciteInputInputEvent.defaultPrevented) { this.value = this.previousValue; this.localizedValue = this.type === "number" ? numberStringFormatter.localize(this.previousValue) : this.previousValue; } else if (committing) { this.emitChangeIfUserModified(); } } }; this.inputKeyUpHandler = () => { window.clearInterval(this.nudgeNumberValueIntervalId); }; this.alignment = "start"; this.autofocus = false; this.clearable = false; this.disabled = false; this.form = undefined; this.groupSeparator = false; this.hidden = false; this.icon = undefined; this.iconFlipRtl = false; this.label = undefined; this.loading = false; this.numberingSystem = undefined; this.localeFormat = false; this.max = undefined; this.min = undefined; this.maxLength = undefined; this.minLength = undefined; this.name = undefined; this.numberButtonType = "vertical"; this.placeholder = undefined; this.prefixText = undefined; this.readOnly = false; this.required = false; this.scale = "m"; this.status = "idle"; this.step = undefined; this.autocomplete = undefined; this.pattern = undefined; this.accept = undefined; this.multiple = false; this.inputMode = "text"; this.enterKeyHint = undefined; this.suffixText = undefined; this.editingEnabled = false; this.type = "text"; this.value = ""; this.files = undefined; this.messages = undefined; this.messageOverrides = undefined; this.defaultMessages = undefined; this.effectiveLocale = ""; this.localizedValue = undefined; this.slottedActionElDisabledInternally = false; } disabledWatcher() { this.setDisabledAction(); } /** watcher to update number-to-string for max */ maxWatcher() { this.maxString = this.max?.toString() || null; } /** watcher to update number-to-string for min */ minWatcher() { this.minString = this.min?.toString() || null; } onMessagesChange() { /* wired up by t9n util */ } valueWatcher(newValue, previousValue) { if (!this.userChangedValue) { this.setValue({ origin: "direct", previousValue, value: newValue == null || newValue == "" ? "" : this.type === "number" ? isValidNumber(newValue) ? newValue : this.previousValue || "" : newValue }); this.warnAboutInvalidNumberValue(newValue); } this.userChangedValue = false; } updateRequestedIcon() { this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type); } get isClearable() { return !this.isTextarea && (this.clearable || this.type === "search") && this.value.length > 0; } get isTextarea() { return this.childElType === "textarea"; } effectiveLocaleChange() { updateMessages(this, this.effectiveLocale); } //-------------------------------------------------------------------------- // // Lifecycle // //-------------------------------------------------------------------------- connectedCallback() { connectInteractive(this); connectLocalized(this); connectMessages(this); this.inlineEditableEl = this.el.closest("calcite-inline-editable"); if (this.inlineEditableEl) { this.editingEnabled = this.inlineEditableEl.editingEnabled || false; } connectLabel(this); connectForm(this); this.setPreviousEmittedValue(this.value); this.setPreviousValue(this.value); if (this.type === "number") { this.warnAboutInvalidNumberValue(this.value); this.setValue({ origin: "connected", value: isValidNumber(this.value) ? this.value : "" }); } this.mutationObserver?.observe(this.el, { childList: true }); this.setDisabledAction(); this.el.addEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler); } disconnectedCallback() { disconnectInteractive(this); disconnectLabel(this); disconnectForm(this); disconnectLocalized(this); disconnectMessages(this); this.mutationObserver?.disconnect(); this.el.removeEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler); } async componentWillLoad() { setUpLoadableComponent(this); this.childElType = this.type === "textarea" ? "textarea" : "input"; this.maxString = this.max?.toString(); this.minString = this.min?.toString(); this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type); await setUpMessages(this); } componentDidLoad() { setComponentLoaded(this); } componentShouldUpdate(newValue, oldValue, property) { if (this.type === "number" && property === "value" && newValue && !isValidNumber(newValue)) { this.setValue({ origin: "reset", value: oldValue }); return false; } return true; } componentDidRender() { updateHostInteraction(this); } //-------------------------------------------------------------------------- // // Public Methods // //-------------------------------------------------------------------------- /** Sets focus on the component. */ async setFocus() { await componentLoaded(this); if (this.type === "number") { this.childNumberEl?.focus(); } else { this.childEl?.focus(); } } /** Selects the text of the component's `value`. */ async selectText() { if (this.type === "number") { this.childNumberEl?.select(); } else { this.childEl?.select(); } } // TODO: refactor so we don't need to sync the internals in color-picker // https://github.com/Esri/calcite-components/issues/6100 /** @internal */ async internalSyncChildElValue() { if (this.type === "number") { this.childNumberEl.value = this.value; } else { this.childEl.value = this.value; } } onLabelClick() { this.setFocus(); } incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent) { const { value } = this; const adjustment = direction === "up" ? 1 : -1; const inputStep = this.step === "any" ? 1 : Math.abs(this.step || 1); const inputVal = new BigDecimal(value !== "" ? value : "0"); const nudgedValue = inputVal.add(`${inputStep * adjustment}`); const nudgedValueBelowInputMin = () => typeof inputMin === "number" && !isNaN(inputMin) && nudgedValue.subtract(`${inputMin}`).isNegative; const nudgedValueAboveInputMax = () => typeof inputMax === "number" && !isNaN(inputMax) && !nudgedValue.subtract(`${inputMax}`).isNegative; const finalValue = nudgedValueBelowInputMin() ? `${inputMin}` : nudgedValueAboveInputMax() ? `${inputMax}` : nudgedValue.toString(); this.setValue({ committing: true, nativeEvent, origin: "user", value: finalValue }); } onFormReset() { this.setValue({ origin: "reset", value: this.defaultValue }); } syncHiddenFormInput(input) { const { type } = this; input.type = type; if (type === "number") { input.min = this.min?.toString(10) ?? ""; input.max = this.max?.toString(10) ?? ""; } else if (type === "text") { if (this.minLength != null) { input.minLength = this.minLength; } if (this.maxLength != null) { input.maxLength = this.maxLength; } } } setDisabledAction() { const slottedActionEl = getSlotted(this.el, "action"); if (!slottedActionEl) { return; } if (this.disabled) { if (slottedActionEl.getAttribute("disabled") == null) { this.slottedActionElDisabledInternally = true; } slottedActionEl.setAttribute("disabled", ""); } else if (this.slottedActionElDisabledInternally) { slottedActionEl.removeAttribute("disabled"); this.slottedActionElDisabledInternally = false; } } normalizeValue(value) { return this.type === "number" ? (isValidNumber(value) ? value : "") : value; } warnAboutInvalidNumberValue(value) { if (this.type === "number" && value && !isValidNumber(value)) { console.warn(`The specified value "${value}" cannot be parsed, or is out of range.`); } } // -------------------------------------------------------------------------- // // Render Methods // // -------------------------------------------------------------------------- render() { const dir = getElementDir(this.el); const loader = (h("div", { class: CSS.loader }, h("calcite-progress", { label: this.messages.loading, type: "indeterminate" }))); const inputClearButton = (h("button", { "aria-label": this.messages.clear, class: CSS.clearButton, disabled: this.disabled || this.readOnly, onClick: this.clearInputValue, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "x", scale: this.scale === "l" ? "m" : "s" }))); const iconEl = (h("calcite-icon", { class: CSS.inputIcon, flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: this.scale === "l" ? "m" : "s" })); const isHorizontalNumberButton = this.numberButtonType === "horizontal"; const numberButtonsHorizontalUp = (h("button", { "aria-hidden": "true", class: { [CSS.numberButtonItem]: true, [CSS.buttonItemHorizontal]: isHorizontalNumberButton }, "data-adjustment": "up", disabled: this.disabled || this.readOnly, onPointerDown: this.numberButtonPointerDownHandler, onPointerOut: this.numberButtonPointerUpAndOutHandler, onPointerUp: this.numberButtonPointerUpAndOutHandler, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "chevron-up", scale: this.scale === "l" ? "m" : "s" }))); const numberButtonsHorizontalDown = (h("button", { "aria-hidden": "true", class: { [CSS.numberButtonItem]: true, [CSS.buttonItemHorizontal]: isHorizontalNumberButton }, "data-adjustment": "down", disabled: this.disabled || this.readOnly, onPointerDown: this.numberButtonPointerDownHandler, onPointerOut: this.numberButtonPointerUpAndOutHandler, onPointerUp: this.numberButtonPointerUpAndOutHandler, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "chevron-down", scale: this.scale === "l" ? "m" : "s" }))); const numberButtonsVertical = (h("div", { class: CSS.numberButtonWrapper }, numberButtonsHorizontalUp, numberButtonsHorizontalDown)); const prefixText = h("div", { class: CSS.prefix }, this.prefixText); const suffixText = h("div", { class: CSS.suffix }, this.suffixText); const localeNumberInput = this.type === "number" ? (h("input", { accept: this.accept, "aria-label": getLabelText(this), autocomplete: this.autocomplete, autofocus: this.autofocus ? true : null, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.enterKeyHint, inputMode: this.inputMode, key: "localized-input", maxLength: this.maxLength, minLength: this.minLength, multiple: this.multiple, name: undefined, onBlur: this.inputBlurHandler, onFocus: this.inputFocusHandler, onInput: this.inputNumberInputHandler, onKeyDown: this.inputNumberKeyDownHandler, onKeyUp: this.inputKeyUpHandler, pattern: this.pattern, placeholder: this.placeholder || "", readOnly: this.readOnly, type: "text", value: this.localizedValue, // eslint-disable-next-line react/jsx-sort-props ref: this.setChildNumberElRef })) : null; const childEl = this.type !== "number" ? [ h(this.childElType, { accept: this.accept, "aria-label": getLabelText(this), autocomplete: this.autocomplete, autofocus: this.autofocus ? true : null, class: { [CSS.editingEnabled]: this.editingEnabled, [CSS.inlineChild]: !!this.inlineEditableEl }, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.enterKeyHint, inputMode: this.inputMode, max: this.maxString, maxLength: this.maxLength, min: this.minString, minLength: this.minLength, multiple: this.multiple, name: this.name, onBlur: this.inputBlurHandler, onChange: this.inputChangeHandler, onFocus: this.inputFocusHandler, onInput: this.inputInputHandler, onKeyDown: this.inputKeyDownHandler, onKeyUp: this.inputKeyUpHandler, pattern: this.pattern, placeholder: this.placeholder || "", readOnly: this.readOnly, required: this.required ? true : null, step: this.step, tabIndex: this.disabled || (this.inlineEditableEl && !this.editingEnabled) ? -1 : null, type: this.type, value: this.value, // eslint-disable-next-line react/jsx-sort-props ref: this.setChildElRef }), this.isTextarea ? (h("div", { class: CSS.resizeIconWrapper }, h("calcite-icon", { icon: "chevron-down", scale: this.scale === "l" ? "m" : "s" }))) : null ] : null; return (h(Host, { onClick: this.clickHandler, onKeyDown: this.keyDownHandler }, h("div", { class: { [CSS.inputWrapper]: true, [CSS_UTILITY.rtl]: dir === "rtl" } }, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly ? numberButtonsHorizontalDown : null, this.prefixText ? prefixText : null, h("div", { class: CSS.wrapper }, localeNumberInput, childEl, this.isClearable ? inputClearButton : null, this.requestedIcon ? iconEl : null, this.loading ? loader : null), h("div", { class: CSS.actionWrapper }, h("slot", { name: SLOTS.action })), this.type === "number" && this.numberButtonType === "vertical" && !this.readOnly ? numberButtonsVertical : null, this.suffixText ? suffixText : null, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly ? numberButtonsHorizontalUp : null, h(HiddenFormInputSlot, { component: this })))); } static get is() { return "calcite-input"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["input.scss"] }; } static get styleUrls() { return { "$": ["input.css"] }; } static get assetsDirs() { return ["assets"]; } static get properties() { return { "alignment": { "type": "string", "mutable": false, "complexType": { "original": "Position", "resolved": "\"end\" | \"start\"", "references": { "Position": { "location": "import", "path": "../interfaces" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the text alignment of the component's value." }, "attribute": "alignment", "reflect": true, "defaultValue": "\"start\"" }, "autofocus": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[autofocus](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus)" }], "text": "When `true`, the component is focused on page load. Only one element can contain `autofocus`. If multiple elements have `autofocus`, the first element will receive focus." }, "attribute": "autofocus", "reflect": true, "defaultValue": "false" }, "clearable": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, a clear button is displayed when the component has a value. The clear button shows by default for `\"search\"`, `\"time\"`, and `\"date\"` types, and will not display for the `\"textarea\"` type." }, "attribute": "clearable", "reflect": true, "defaultValue": "false" }, "disabled": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled)" }], "text": "When `true`, interaction is prevented and the component is displayed with lower opacity." }, "attribute": "disabled", "reflect": true, "defaultValue": "false" }, "form": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "The ID of the form that will be associated with the component.\n\nWhen not set, the component will be associated with its ancestor form element, if any." }, "attribute": "form", "reflect": true }, "groupSeparator": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, number values are displayed with a group separator corresponding to the language and country format." }, "attribute": "group-separator", "reflect": true, "defaultValue": "false" }, "hidden": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[hidden](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden)" }], "text": "When `true`, the component will not be visible." }, "attribute": "hidden", "reflect": true, "defaultValue": "false" }, "icon": { "type": "any", "mutable": false, "complexType": { "original": "string | boolean", "resolved": "boolean | string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, shows a default recommended icon. Alternatively, pass a Calcite UI Icon name to display a specific icon." }, "attribute": "icon", "reflect": true }, "iconFlipRtl": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, the icon will be flipped when the element direction is right-to-left (`\"rtl\"`)." }, "attribute": "icon-flip-rtl", "reflect": true, "defaultValue": "false" }, "label": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Accessible name for the component." }, "attribute": "label", "reflect": false }, "loading": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, a busy indicator is displayed." }, "attribute": "loading", "reflect": true, "defaultValue": "false" }, "numberingSystem": { "type": "string", "mutable": false, "complexType": { "original": "NumberingSystem", "resolved": "\"arab\" | \"arabext\" | \"bali\" | \"beng\" | \"deva\" | \"fullwide\" | \"gujr\" | \"guru\" | \"hanidec\" | \"khmr\" | \"knda\" | \"laoo\" | \"latn\" | \"limb\" | \"mlym\" | \"mong\" | \"mymr\" | \"orya\" | \"tamldec\" | \"telu\" | \"thai\" | \"tibt\"", "references": { "NumberingSystem": { "location": "import", "path": "../../utils/locale" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the Unicode numeral system used by the component for localization." }, "attribute": "numbering-system", "reflect": true }, "localeFormat": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "When `true`, uses locale formatting for numbers." }, "attribute": "locale-format", "reflect": false, "defaultValue": "false" }, "max": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[max](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max)" }], "text": "Specifies the maximum value for type \"number\"." }, "attribute": "max", "reflect": true }, "min": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[min](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min)" }], "text": "Specifies the minimum value for `type=\"number\"`." }, "attribute": "min", "reflect": true }, "maxLength": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[maxlength](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength)" }], "text": "Specifies the maximum length of text for the component's value." }, "attribute": "max-length", "reflect": true }, "minLength": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[minlength](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength)" }], "text": "Specifies the minimum length of text for the component's value." }, "attribute": "min-length", "reflect": true }, "name": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[name](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name)" }], "text": "Specifies the name of the component.\n\nRequired to pass the component's `value` on form submission." }, "attribute": "name", "reflect": true }, "numberButtonType": { "type": "string", "mutable": false, "complexType": { "original": "InputPlacement", "resolved": "\"horizontal\" | \"none\" | \"vertical\"", "references": { "InputPlacement": { "location": "import", "path": "./interfaces" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the placement of the buttons for `type=\"number\"`." }, "attribute": "number-button-type", "reflect": true, "defaultValue": "\"vertical\"" }, "placeholder": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[placeholder](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder)" }], "text": "Specifies placeholder text for the component." }, "attribute": "placeholder", "reflect": false }, "prefixText": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Adds text to the start of the component." }, "attribute": "prefix-text", "reflect": false }, "readOnly": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)" }], "text": "When `true`, the component's value can be read, but cannot be modified." }, "attribute": "read-only", "reflect": true, "defaultValue": "false" }, "required": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, the component must have a value in order for the form to submit." }, "attribute": "required", "reflect": true, "defaultValue": "false" }, "scale": { "type": "string", "mutable": false, "complexType": { "original": "Scale", "resolved": "\"l\" | \"m\" | \"s\"", "references": { "Scale": { "location": "import", "path": "../interfaces" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the size of the component." }, "attribute": "scale", "reflect": true, "defaultValue": "\"m\"" }, "status": { "type": "string", "mutable": false, "complexType": { "original": "Status", "resolved": "\"idle\" | \"invalid\" | \"valid\"", "references": { "Status": { "location": "import", "path": "../interfaces" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the status of the input field, which determines message and icons." }, "attribute": "status", "reflect": true, "defaultValue": "\"idle\"" }, "step": { "type": "any", "mutable": false, "complexType": { "original": "number | \"any\"", "resolved": "\"any\" | number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step)" }], "text": "Specifies the granularity the component's `value` must adhere to." }, "attribute": "step", "reflect": true }, "autocomplete": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)" }], "text": "Specifies the type of content to autocomplete, for use in forms.\nRead the native attribute's documentation on MDN for more info." }, "attribute": "autocomplete", "reflect": false }, "pattern": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern)" }], "text": "Specifies a regex pattern the component's `value` must match for validation.\nRead the native attribute's documentation on MDN for more info." }, "attribute": "pattern", "reflect": false }, "accept": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern)" }], "text": "Specifies a comma separated list of unique file type specifiers for limiting accepted file types.\nThis property only has an effect when `type` is \"file\".\nRead the native attribute's documentation on MDN for more info." }, "attribute": "accept", "reflect": false }, "multiple": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple)" }], "text": "When `true`, the component can accept more than one value.\nThis property only has an effect when `type` is \"email\" or \"file\".\nRead the native attribute's documentation on MDN for more info." }, "attribute": "multiple", "reflect": false, "defaultValue": "false" }, "inputMode": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode)" }], "text": "Specifies the type of content to help devices display an appropriate virtual keyboard.\nRead the native attribute's documentation on MDN for more info." }, "attribute": "input-mode", "reflect": false, "defaultValue": "\"text\"" }, "enterKeyHint": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint)" }], "text": "Specifies the action label or icon for the Enter key on virtual keyboards.\nRead the native attribute's documentation on MDN for more info." }, "attribute": "enter-key-hint", "reflect": false }, "suffixText": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Adds text to the end of the component." }, "attribute": "suffix-text", "reflect": false }, "editingEnabled": { "type": "boolean", "mutable": true, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "" }, "attribute": "editing-enabled", "reflect": true, "defaultValue": "false" }, "type": { "type": "string", "mutable": false, "complexType": { "original": "| \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"email\"\n | \"file\"\n | \"image\"\n | \"month\"\n | \"number\"\n | \"password\"\n | \"search\"\n | \"tel\"\n | \"text\"\n | \"textarea\"\n | \"time\"\n | \"url\"\n | \"week\"", "resolved": "\"color\" | \"date\" | \"datetime-local\" | \"email\" | \"file\" | \"image\" | \"month\" | \"number\" | \"password\" | \"search\" | \"tel\" | \"text\" | \"textarea\" | \"time\" | \"url\" | \"week\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the component type.\n\nNote that the following `type`s add type-specific icons by default: `\"date\"`, `\"email\"`, `\"password\"`, `\"search\"`, `\"tel\"`, `\"time\"`." }, "attribute": "type", "reflect": true, "defaultValue": "\"text\"" }, "value": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "The component's value." }, "attribute": "value", "reflect": false, "defaultValue": "\"\"" }, "files": { "type": "unknown", "mutable": false, "complexType": { "original": "FileList | undefined", "resolved": "FileList", "references": { "FileList": { "location": "global" } } }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files" }], "text": "When `type` is `\"file\"`, specifies the component's selected files." } }, "messages": { "type": "unknown", "mutable": true, "complexType": { "original": "InputMessages", "resolved": "{ clear: string; loading: string; }", "references": { "InputMessages": { "location": "import", "path": "./assets/input/t9n" } } }, "required": false, "optional": false, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "Made into a prop for testing purposes only" } }, "messageOverrides": { "type": "unknown", "mutable": true, "complexType": { "original": "Partial<InputMessages>", "resolved": "{ clear?: string; loading?: string; }", "references": { "Partial": { "location": "global" }, "InputMessages": { "location": "import", "path": "./assets/input/t9n" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Use this property to override individual strings used by the component." } } }; } static get states() { return { "defaultMessages": {}, "effectiveLocale": {}, "localizedValue": {}, "slottedActionElDisabledInternally": {} }; } static get events() { return [{ "method": "calciteInternalInputFocus", "name": "calciteInternalInputFocus", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "" }, "complexType": { "original": "void", "resolved": "void", "references": {} } }, { "method": "calciteInternalInputBlur", "name": "calciteInternalInputBlur", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "" }, "complexType": { "original": "void", "resolved": "void", "references": {} }