123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import { h, Host } from "@stencil/core";
- import { getElementDir, getElementProp, getSlotted, isPrimaryPointerButton, setRequestedIcon } from "../../utils/dom";
- import { CSS, SLOTS, TEXT } from "./resources";
- import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label";
- import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form";
- import { numberStringFormatter, defaultNumberingSystem, disconnectLocalized, connectLocalized, updateEffectiveLocale } from "../../utils/locale";
- import { numberKeys } from "../../utils/key";
- import { isValidNumber, parseNumberString, sanitizeNumberString } from "../../utils/number";
- import { CSS_UTILITY, TEXT as COMMON_TEXT } from "../../utils/resources";
- import { decimalPlaces } from "../../utils/math";
- import { createObserver } from "../../utils/observers";
- import { updateHostInteraction } from "../../utils/interactive";
- /**
- * @slot action - A slot for positioning a button next to the component.
- */
- export class InputNumber {
- constructor() {
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /** Specifies the text alignment of the component's value. */
- this.alignment = "start";
- /**
- * When `true`, the component is focused on page load.
- *
- * @mdn [autofocus](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus)
- */
- this.autofocus = false;
- /**
- * When `true`, a clear button is displayed when the component has a value.
- */
- this.clearable = false;
- /**
- * When `true`, interaction is prevented and the component is displayed with lower opacity.
- *
- * @mdn [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled)
- */
- this.disabled = false;
- /**
- * When `true`, number values are displayed with a group separator corresponding to the language and country format.
- */
- this.groupSeparator = false;
- /**
- * When `true`, the component will not be visible.
- *
- * @mdn [hidden](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden)
- */
- this.hidden = false;
- /**
- * Accessible name that will appear while loading.
- *
- * @default "Loading"
- */
- this.intlLoading = COMMON_TEXT.loading;
- /** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
- this.iconFlipRtl = false;
- /** When `true`, the component is in the loading state and `calcite-progress` is displayed. */
- this.loading = false;
- /**
- * Toggles locale formatting for numbers.
- *
- * @internal
- */
- this.localeFormat = false;
- /** Specifies the placement of the buttons. */
- this.numberButtonType = "vertical";
- /**
- * When `true`, the component's value can be read, but cannot be modified.
- *
- * @mdn [readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)
- */
- this.readOnly = false;
- /** When `true`, the component must have a value in order for the form to submit. */
- this.required = false;
- /** Specifies the size of the component. */
- this.scale = "m";
- /** Specifies the status of the input field, which determines message and icons. */
- this.status = "idle";
- /**
- * @internal
- */
- this.editingEnabled = false;
- /** The component's value. */
- this.value = "";
- this.previousValueOrigin = "initial";
- this.mutationObserver = createObserver("mutation", () => this.setDisabledAction());
- this.userChangedValue = false;
- //--------------------------------------------------------------------------
- //
- // State
- //
- //--------------------------------------------------------------------------
- this.effectiveLocale = "";
- //--------------------------------------------------------------------------
- //
- // 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.setNumberValue({
- committing: true,
- nativeEvent,
- origin: "user",
- value: ""
- });
- };
- this.emitChangeIfUserModified = () => {
- if (this.previousValueOrigin === "user" && this.value !== this.previousEmittedValue) {
- this.calciteInputNumberChange.emit();
- }
- this.previousEmittedValue = this.value;
- };
- this.inputNumberBlurHandler = () => {
- this.calciteInternalInputNumberBlur.emit();
- this.emitChangeIfUserModified();
- };
- this.inputNumberFocusHandler = (event) => {
- const slottedActionEl = getSlotted(this.el, "action");
- if (event.target !== slottedActionEl) {
- this.setFocus();
- }
- this.calciteInternalInputNumberFocus.emit();
- };
- 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.setNumberValue({
- nativeEvent,
- origin: "user",
- value: parseNumberString(delocalizedValue)
- });
- this.childNumberEl.value = this.localizedValue;
- }
- else {
- this.setNumberValue({
- nativeEvent,
- origin: "user",
- value: delocalizedValue
- });
- }
- };
- this.inputNumberKeyDownHandler = (event) => {
- if (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) {
- return;
- }
- const inputMax = this.maxString ? parseFloat(this.maxString) : null;
- const inputMin = this.minString ? parseFloat(this.minString) : null;
- const valueNudgeDelayInMs = 100;
- 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.nudgeButtonPointerUpAndOutHandler = (event) => {
- if (!isPrimaryPointerButton(event)) {
- return;
- }
- window.clearInterval(this.nudgeNumberValueIntervalId);
- };
- this.nudgeButtonPointerDownHandler = (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.setNumberValue({
- value: event.target.value,
- origin: "direct"
- });
- }
- event.stopPropagation();
- };
- this.setChildNumberElRef = (el) => {
- this.childNumberEl = el;
- };
- this.setInputNumberValue = (newInputValue) => {
- if (!this.childNumberEl) {
- return;
- }
- this.childNumberEl.value = newInputValue;
- };
- this.setPreviousEmittedNumberValue = (newPreviousEmittedValue) => {
- this.previousEmittedValue = isValidNumber(newPreviousEmittedValue)
- ? newPreviousEmittedValue
- : "";
- };
- this.setPreviousNumberValue = (newPreviousValue) => {
- this.previousValue = isValidNumber(newPreviousValue) ? newPreviousValue : "";
- };
- this.setNumberValue = ({ committing = false, nativeEvent, origin, previousValue, value }) => {
- numberStringFormatter.numberFormatOptions = {
- locale: this.effectiveLocale,
- numberingSystem: this.numberingSystem,
- useGrouping: this.groupSeparator
- };
- const sanitizedValue = sanitizeNumberString((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.setPreviousNumberValue(previousValue || this.value);
- this.previousValueOrigin = origin;
- this.userChangedValue = origin === "user" && this.value !== newValue;
- this.value = newValue;
- this.localizedValue = newLocalizedValue;
- if (origin === "direct") {
- this.setInputNumberValue(newLocalizedValue);
- }
- if (nativeEvent) {
- const calciteInputNumberInputEvent = this.calciteInputNumberInput.emit({
- element: this.childNumberEl,
- nativeEvent,
- value: this.value
- });
- if (calciteInputNumberInputEvent.defaultPrevented) {
- const previousLocalizedValue = numberStringFormatter.localize(this.previousValue);
- this.value = this.previousValue;
- this.localizedValue = previousLocalizedValue;
- }
- else if (committing) {
- this.emitChangeIfUserModified();
- }
- }
- };
- this.inputNumberKeyUpHandler = () => {
- window.clearInterval(this.nudgeNumberValueIntervalId);
- };
- }
- disabledWatcher() {
- this.setDisabledAction();
- }
- localeChanged() {
- updateEffectiveLocale(this);
- }
- /** watcher to update number-to-string for max */
- maxWatcher() {
- var _a;
- this.maxString = ((_a = this.max) === null || _a === void 0 ? void 0 : _a.toString()) || null;
- }
- /** watcher to update number-to-string for min */
- minWatcher() {
- var _a;
- this.minString = ((_a = this.min) === null || _a === void 0 ? void 0 : _a.toString()) || null;
- }
- valueWatcher(newValue, previousValue) {
- if (!this.userChangedValue) {
- this.setNumberValue({
- origin: "direct",
- previousValue,
- value: newValue == null || newValue == ""
- ? ""
- : isValidNumber(newValue)
- ? newValue
- : this.previousValue || ""
- });
- this.warnAboutInvalidNumberValue(newValue);
- }
- this.userChangedValue = false;
- }
- updateRequestedIcon() {
- this.requestedIcon = setRequestedIcon({}, this.icon, "number");
- }
- get isClearable() {
- return this.clearable && this.value.length > 0;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- var _a;
- connectLocalized(this);
- this.scale = getElementProp(this.el, "scale", this.scale);
- this.status = getElementProp(this.el, "status", this.status);
- this.inlineEditableEl = this.el.closest("calcite-inline-editable");
- if (this.inlineEditableEl) {
- this.editingEnabled = this.inlineEditableEl.editingEnabled || false;
- }
- connectLabel(this);
- connectForm(this);
- this.setPreviousEmittedNumberValue(this.value);
- this.setPreviousNumberValue(this.value);
- this.warnAboutInvalidNumberValue(this.value);
- this.setNumberValue({
- origin: "connected",
- value: isValidNumber(this.value) ? this.value : ""
- });
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
- this.setDisabledAction();
- this.el.addEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler);
- }
- disconnectedCallback() {
- var _a;
- disconnectLabel(this);
- disconnectForm(this);
- disconnectLocalized(this);
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
- this.el.removeEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler);
- }
- componentWillLoad() {
- var _a, _b;
- this.maxString = (_a = this.max) === null || _a === void 0 ? void 0 : _a.toString();
- this.minString = (_b = this.min) === null || _b === void 0 ? void 0 : _b.toString();
- this.requestedIcon = setRequestedIcon({}, this.icon, "number");
- }
- componentShouldUpdate(newValue, oldValue, property) {
- if (property === "value" && newValue && !isValidNumber(newValue)) {
- this.setNumberValue({
- origin: "reset",
- value: oldValue
- });
- return false;
- }
- return true;
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.childNumberEl) === null || _a === void 0 ? void 0 : _a.focus();
- }
- /** Selects all text of the component's `value`. */
- async selectText() {
- var _a;
- (_a = this.childNumberEl) === null || _a === void 0 ? void 0 : _a.select();
- }
- onLabelClick() {
- this.setFocus();
- }
- incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent) {
- const { value } = this;
- const inputStep = this.step === "any" ? 1 : Math.abs(this.step || 1);
- const inputVal = value && value !== "" ? parseFloat(value) : 0;
- const adjustment = direction === "up" ? 1 : -1;
- const nudgedValue = inputVal + inputStep * adjustment;
- const finalValue = (typeof inputMin === "number" && !isNaN(inputMin) && nudgedValue < inputMin) ||
- (typeof inputMax === "number" && !isNaN(inputMax) && nudgedValue > inputMax)
- ? inputVal
- : nudgedValue;
- const inputValPlaces = decimalPlaces(inputVal);
- const inputStepPlaces = decimalPlaces(inputStep);
- this.setNumberValue({
- committing: true,
- nativeEvent,
- origin: "user",
- value: finalValue.toFixed(Math.max(inputValPlaces, inputStepPlaces))
- });
- }
- onFormReset() {
- this.setNumberValue({
- origin: "reset",
- value: this.defaultValue
- });
- }
- syncHiddenFormInput(input) {
- var _a, _b, _c, _d;
- input.type = "number";
- input.min = (_b = (_a = this.min) === null || _a === void 0 ? void 0 : _a.toString(10)) !== null && _b !== void 0 ? _b : "";
- input.max = (_d = (_c = this.max) === null || _c === void 0 ? void 0 : _c.toString(10)) !== null && _d !== void 0 ? _d : "";
- }
- setDisabledAction() {
- const slottedActionEl = getSlotted(this.el, "action");
- if (!slottedActionEl) {
- return;
- }
- this.disabled
- ? slottedActionEl.setAttribute("disabled", "")
- : slottedActionEl.removeAttribute("disabled");
- }
- warnAboutInvalidNumberValue(value) {
- if (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.intlLoading, type: "indeterminate" })));
- const inputClearButton = (h("button", { "aria-label": this.intlClear || TEXT.clear, class: CSS.clearButton, disabled: this.disabled || this.readOnly, onClick: this.clearInputValue, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "x", scale: "s" })));
- const iconEl = (h("calcite-icon", { class: CSS.inputIcon, flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: "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.nudgeButtonPointerDownHandler, onPointerOut: this.nudgeButtonPointerUpAndOutHandler, onPointerUp: this.nudgeButtonPointerUpAndOutHandler, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "chevron-up", scale: "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.nudgeButtonPointerDownHandler, onPointerOut: this.nudgeButtonPointerUpAndOutHandler, onPointerUp: this.nudgeButtonPointerUpAndOutHandler, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "chevron-down", scale: "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 childEl = (h("input", { "aria-label": getLabelText(this), autofocus: this.autofocus ? true : null, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.el.enterKeyHint, inputMode: this.el.inputMode, key: "localized-input", maxLength: this.maxLength, minLength: this.minLength, name: undefined, onBlur: this.inputNumberBlurHandler, onFocus: this.inputNumberFocusHandler, onInput: this.inputNumberInputHandler, onKeyDown: this.inputNumberKeyDownHandler, onKeyUp: this.inputNumberKeyUpHandler, placeholder: this.placeholder || "", readOnly: this.readOnly, ref: this.setChildNumberElRef, type: "text", value: this.localizedValue }));
- return (h(Host, { onClick: this.inputNumberFocusHandler, onKeyDown: this.keyDownHandler }, h("div", { class: { [CSS.inputWrapper]: true, [CSS_UTILITY.rtl]: dir === "rtl" } }, this.numberButtonType === "horizontal" && !this.readOnly
- ? numberButtonsHorizontalDown
- : null, this.prefixText ? prefixText : null, h("div", { class: CSS.wrapper }, childEl, this.isClearable ? inputClearButton : null, this.requestedIcon ? iconEl : null, this.loading ? loader : null), h("div", { class: CSS.actionWrapper }, h("slot", { name: SLOTS.action })), this.numberButtonType === "vertical" && !this.readOnly ? numberButtonsVertical : null, this.suffixText ? suffixText : null, this.numberButtonType === "horizontal" && !this.readOnly
- ? numberButtonsHorizontalUp
- : null, h(HiddenFormInputSlot, { component: this }))));
- }
- static get is() { return "calcite-input-number"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() {
- return {
- "$": ["input-number.scss"]
- };
- }
- static get styleUrls() {
- return {
- "$": ["input-number.css"]
- };
- }
- 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."
- },
- "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."
- },
- "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"
- },
- "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
- },
- "intlClear": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "A text label that will appear on the clear button for screen readers."
- },
- "attribute": "intl-clear",
- "reflect": false
- },
- "intlLoading": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [{
- "name": "default",
- "text": "\"Loading\""
- }],
- "text": "Accessible name that will appear while loading."
- },
- "attribute": "intl-loading",
- "reflect": false,
- "defaultValue": "COMMON_TEXT.loading"
- },
- "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": true,
- "docs": {
- "tags": [],
- "text": "Accessible name for the component's button or hyperlink."
- },
- "attribute": "label",
- "reflect": false
- },
- "loading": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When `true`, the component is in the loading state and `calcite-progress` is displayed."
- },
- "attribute": "loading",
- "reflect": true,
- "defaultValue": "false"
- },
- "locale": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "deprecated",
- "text": "set the global `lang` attribute on the element instead."
- }, {
- "name": "mdn",
- "text": "[lang](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)"
- }],
- "text": "Specifies the BCP 47 language tag for the desired language and country format."
- },
- "attribute": "locale",
- "reflect": 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": true,
- "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": "Toggles 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": true,
- "docs": {
- "tags": [{
- "name": "mdn",
- "text": "[max](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max)"
- }],
- "text": "Specifies the maximum value."
- },
- "attribute": "max",
- "reflect": true
- },
- "min": {
- "type": "number",
- "mutable": false,
- "complexType": {
- "original": "number",
- "resolved": "number",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [{
- "name": "mdn",
- "text": "[min](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min)"
- }],
- "text": "Specifies the minimum value."
- },
- "attribute": "min",
- "reflect": true
- },
- "maxLength": {
- "type": "number",
- "mutable": false,
- "complexType": {
- "original": "number",
- "resolved": "number",
- "references": {}
- },
- "required": false,
- "optional": true,
- "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": true,
- "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."
- },
- "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": true,
- "docs": {
- "tags": [],
- "text": "Specifies the placement of the buttons."
- },
- "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": true,
- "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": true,
- "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": true,
- "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": true,
- "docs": {
- "tags": [{
- "name": "mdn",
- "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step)"
- }],
- "text": "Specifies the granularity that the component's value must adhere to."
- },
- "attribute": "step",
- "reflect": true
- },
- "suffixText": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "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"
- },
- "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": "\"\""
- }
- };
- }
- static get states() {
- return {
- "effectiveLocale": {},
- "localizedValue": {}
- };
- }
- static get events() {
- return [{
- "method": "calciteInternalInputNumberFocus",
- "name": "calciteInternalInputNumberFocus",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [{
- "name": "internal",
- "text": undefined
- }],
- "text": ""
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }, {
- "method": "calciteInternalInputNumberBlur",
- "name": "calciteInternalInputNumberBlur",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [{
- "name": "internal",
- "text": undefined
- }],
- "text": ""
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }, {
- "method": "calciteInputNumberInput",
- "name": "calciteInputNumberInput",
- "bubbles": true,
- "cancelable": true,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires each time a new value is typed.\n\n**Note:**: The `el` and `value` event payload props are deprecated, please use the event's `target`/`currentTarget` instead"
- },
- "complexType": {
- "original": "DeprecatedEventPayload",
- "resolved": "any",
- "references": {
- "DeprecatedEventPayload": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- }
- }, {
- "method": "calciteInputNumberChange",
- "name": "calciteInputNumberChange",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires each time a new value is typed and committed."
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }];
- }
- static get methods() {
- return {
- "setFocus": {
- "complexType": {
- "signature": "() => Promise<void>",
- "parameters": [],
- "references": {
- "Promise": {
- "location": "global"
- }
- },
- "return": "Promise<void>"
- },
- "docs": {
- "text": "Sets focus on the component.",
- "tags": []
- }
- },
- "selectText": {
- "complexType": {
- "signature": "() => Promise<void>",
- "parameters": [],
- "references": {
- "Promise": {
- "location": "global"
- }
- },
- "return": "Promise<void>"
- },
- "docs": {
- "text": "Selects all text of the component's `value`.",
- "tags": []
- }
- }
- };
- }
- static get elementRef() { return "el"; }
- static get watchers() {
- return [{
- "propName": "disabled",
- "methodName": "disabledWatcher"
- }, {
- "propName": "locale",
- "methodName": "localeChanged"
- }, {
- "propName": "max",
- "methodName": "maxWatcher"
- }, {
- "propName": "min",
- "methodName": "minWatcher"
- }, {
- "propName": "value",
- "methodName": "valueWatcher"
- }, {
- "propName": "icon",
- "methodName": "updateRequestedIcon"
- }];
- }
- }
|