input.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { h, Host } from "@stencil/core";
  7. import { getElementDir, getElementProp, getSlotted, isPrimaryPointerButton, setRequestedIcon } from "../../utils/dom";
  8. import { CSS, INPUT_TYPE_ICONS, SLOTS, TEXT } from "./resources";
  9. import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label";
  10. import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form";
  11. import { defaultNumberingSystem, numberStringFormatter, disconnectLocalized, connectLocalized, updateEffectiveLocale } from "../../utils/locale";
  12. import { numberKeys } from "../../utils/key";
  13. import { isValidNumber, parseNumberString, sanitizeNumberString } from "../../utils/number";
  14. import { CSS_UTILITY, TEXT as COMMON_TEXT } from "../../utils/resources";
  15. import { decimalPlaces } from "../../utils/math";
  16. import { createObserver } from "../../utils/observers";
  17. import { updateHostInteraction } from "../../utils/interactive";
  18. /**
  19. * @slot action - A slot for positioning a `calcite-button` next to the component.
  20. */
  21. export class Input {
  22. constructor() {
  23. //--------------------------------------------------------------------------
  24. //
  25. // Properties
  26. //
  27. //--------------------------------------------------------------------------
  28. /** Specifies the text alignment of the component's value. */
  29. this.alignment = "start";
  30. /**
  31. * When `true`, the component is focused on page load.
  32. *
  33. * @mdn [autofocus](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus)
  34. */
  35. this.autofocus = false;
  36. /**
  37. * 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.
  38. */
  39. this.clearable = false;
  40. /**
  41. * When `true`, interaction is prevented and the component is displayed with lower opacity.
  42. *
  43. * @mdn [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled)
  44. */
  45. this.disabled = false;
  46. /**
  47. * When `true`, number values are displayed with a group separator corresponding to the language and country format.
  48. */
  49. this.groupSeparator = false;
  50. /**
  51. * When `true`, the component will not be visible.
  52. *
  53. * @mdn [hidden](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden)
  54. */
  55. this.hidden = false;
  56. /**
  57. * Accessible name when the component is loading.
  58. *
  59. * @default "Loading"
  60. */
  61. this.intlLoading = COMMON_TEXT.loading;
  62. /** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
  63. this.iconFlipRtl = false;
  64. /** When `true`, a busy indicator is displayed. */
  65. this.loading = false;
  66. /**
  67. * When `true`, uses locale formatting for numbers.
  68. *
  69. * @internal
  70. */
  71. this.localeFormat = false;
  72. /** Specifies the placement of the buttons for `type="number"`. */
  73. this.numberButtonType = "vertical";
  74. /**
  75. * When `true`, the component's value can be read, but cannot be modified.
  76. *
  77. * @mdn [readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)
  78. */
  79. this.readOnly = false;
  80. /** When `true`, the component must have a value in order for the form to submit. */
  81. this.required = false;
  82. /** Specifies the size of the component. */
  83. this.scale = "m";
  84. /** Specifies the status of the input field, which determines message and icons. */
  85. this.status = "idle";
  86. /**
  87. * @internal
  88. */
  89. this.editingEnabled = false;
  90. /**
  91. * Specifies the component type.
  92. *
  93. * Note that the following `type`s add type-specific icons by default: `"date"`, `"email"`, `"password"`, `"search"`, `"tel"`, `"time"`.
  94. */
  95. this.type = "text";
  96. /** The component's value. */
  97. this.value = "";
  98. /** keep track of the rendered child type */
  99. this.childElType = "input";
  100. this.previousValueOrigin = "initial";
  101. this.mutationObserver = createObserver("mutation", () => this.setDisabledAction());
  102. this.userChangedValue = false;
  103. //--------------------------------------------------------------------------
  104. //
  105. // State
  106. //
  107. //--------------------------------------------------------------------------
  108. this.effectiveLocale = "";
  109. //--------------------------------------------------------------------------
  110. //
  111. // Private Methods
  112. //
  113. //--------------------------------------------------------------------------
  114. this.keyDownHandler = (event) => {
  115. if (this.readOnly || this.disabled) {
  116. return;
  117. }
  118. if (this.isClearable && event.key === "Escape") {
  119. this.clearInputValue(event);
  120. event.preventDefault();
  121. }
  122. if (event.key === "Enter" && !event.defaultPrevented) {
  123. if (submitForm(this)) {
  124. event.preventDefault();
  125. }
  126. }
  127. };
  128. this.clearInputValue = (nativeEvent) => {
  129. this.setValue({
  130. committing: true,
  131. nativeEvent,
  132. origin: "user",
  133. value: ""
  134. });
  135. };
  136. this.emitChangeIfUserModified = () => {
  137. if (this.previousValueOrigin === "user" && this.value !== this.previousEmittedValue) {
  138. this.calciteInputChange.emit();
  139. }
  140. this.previousEmittedValue = this.value;
  141. };
  142. this.inputBlurHandler = () => {
  143. this.calciteInternalInputBlur.emit();
  144. this.emitChangeIfUserModified();
  145. };
  146. this.inputFocusHandler = (event) => {
  147. const slottedActionEl = getSlotted(this.el, "action");
  148. if (event.target !== slottedActionEl) {
  149. this.setFocus();
  150. }
  151. this.calciteInternalInputFocus.emit();
  152. };
  153. this.inputInputHandler = (nativeEvent) => {
  154. if (this.disabled || this.readOnly) {
  155. return;
  156. }
  157. this.setValue({
  158. nativeEvent,
  159. origin: "user",
  160. value: nativeEvent.target.value
  161. });
  162. };
  163. this.inputKeyDownHandler = (event) => {
  164. if (this.disabled || this.readOnly) {
  165. return;
  166. }
  167. if (event.key === "Enter") {
  168. this.emitChangeIfUserModified();
  169. }
  170. };
  171. this.inputNumberInputHandler = (nativeEvent) => {
  172. if (this.disabled || this.readOnly) {
  173. return;
  174. }
  175. const value = nativeEvent.target.value;
  176. numberStringFormatter.numberFormatOptions = {
  177. locale: this.effectiveLocale,
  178. numberingSystem: this.numberingSystem,
  179. useGrouping: this.groupSeparator
  180. };
  181. const delocalizedValue = numberStringFormatter.delocalize(value);
  182. if (nativeEvent.inputType === "insertFromPaste") {
  183. if (!isValidNumber(delocalizedValue)) {
  184. nativeEvent.preventDefault();
  185. }
  186. this.setValue({
  187. nativeEvent,
  188. origin: "user",
  189. value: parseNumberString(delocalizedValue)
  190. });
  191. this.childNumberEl.value = this.localizedValue;
  192. }
  193. else {
  194. this.setValue({
  195. nativeEvent,
  196. origin: "user",
  197. value: delocalizedValue
  198. });
  199. }
  200. };
  201. this.inputNumberKeyDownHandler = (event) => {
  202. if (this.type !== "number" || this.disabled || this.readOnly) {
  203. return;
  204. }
  205. if (event.key === "ArrowUp") {
  206. /* prevent default behavior of moving cursor to the beginning of the input when holding down ArrowUp */
  207. event.preventDefault();
  208. this.nudgeNumberValue("up", event);
  209. return;
  210. }
  211. if (event.key === "ArrowDown") {
  212. this.nudgeNumberValue("down", event);
  213. return;
  214. }
  215. const supportedKeys = [
  216. ...numberKeys,
  217. "ArrowLeft",
  218. "ArrowRight",
  219. "Backspace",
  220. "Delete",
  221. "Enter",
  222. "Escape",
  223. "Tab"
  224. ];
  225. if (event.altKey || event.ctrlKey || event.metaKey) {
  226. return;
  227. }
  228. const isShiftTabEvent = event.shiftKey && event.key === "Tab";
  229. if (supportedKeys.includes(event.key) && (!event.shiftKey || isShiftTabEvent)) {
  230. if (event.key === "Enter") {
  231. this.emitChangeIfUserModified();
  232. }
  233. return;
  234. }
  235. numberStringFormatter.numberFormatOptions = {
  236. locale: this.effectiveLocale,
  237. numberingSystem: this.numberingSystem,
  238. useGrouping: this.groupSeparator
  239. };
  240. if (event.key === numberStringFormatter.decimal) {
  241. if (!this.value && !this.childNumberEl.value) {
  242. return;
  243. }
  244. if (this.value && this.childNumberEl.value.indexOf(numberStringFormatter.decimal) === -1) {
  245. return;
  246. }
  247. }
  248. if (/[eE]/.test(event.key)) {
  249. if (!this.value && !this.childNumberEl.value) {
  250. return;
  251. }
  252. if (this.value && !/[eE]/.test(this.childNumberEl.value)) {
  253. return;
  254. }
  255. }
  256. if (event.key === "-") {
  257. if (!this.value && !this.childNumberEl.value) {
  258. return;
  259. }
  260. if (this.value && this.childNumberEl.value.split("-").length <= 2) {
  261. return;
  262. }
  263. }
  264. event.preventDefault();
  265. };
  266. this.nudgeNumberValue = (direction, nativeEvent) => {
  267. if ((nativeEvent instanceof KeyboardEvent && nativeEvent.repeat) || this.type !== "number") {
  268. return;
  269. }
  270. const inputMax = this.maxString ? parseFloat(this.maxString) : null;
  271. const inputMin = this.minString ? parseFloat(this.minString) : null;
  272. const valueNudgeDelayInMs = 100;
  273. this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent);
  274. if (this.nudgeNumberValueIntervalId) {
  275. window.clearInterval(this.nudgeNumberValueIntervalId);
  276. }
  277. let firstValueNudge = true;
  278. this.nudgeNumberValueIntervalId = window.setInterval(() => {
  279. if (firstValueNudge) {
  280. firstValueNudge = false;
  281. return;
  282. }
  283. this.incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent);
  284. }, valueNudgeDelayInMs);
  285. };
  286. this.numberButtonPointerUpAndOutHandler = () => {
  287. window.clearInterval(this.nudgeNumberValueIntervalId);
  288. };
  289. this.numberButtonPointerDownHandler = (event) => {
  290. if (!isPrimaryPointerButton(event)) {
  291. return;
  292. }
  293. event.preventDefault();
  294. const direction = event.target.dataset.adjustment;
  295. if (!this.disabled) {
  296. this.nudgeNumberValue(direction, event);
  297. }
  298. };
  299. this.hiddenInputChangeHandler = (event) => {
  300. if (event.target.name === this.name) {
  301. const hiddenInputValue = event.target.value;
  302. const value = this.type === "number"
  303. ? isValidNumber(hiddenInputValue)
  304. ? hiddenInputValue
  305. : ""
  306. : hiddenInputValue;
  307. this.setValue({
  308. value,
  309. origin: "direct"
  310. });
  311. }
  312. event.stopPropagation();
  313. };
  314. this.setChildElRef = (el) => {
  315. this.childEl = el;
  316. };
  317. this.setChildNumberElRef = (el) => {
  318. this.childNumberEl = el;
  319. };
  320. this.setInputValue = (newInputValue) => {
  321. if (this.type === "text" && !this.childEl) {
  322. return;
  323. }
  324. if (this.type === "number" && !this.childNumberEl) {
  325. return;
  326. }
  327. this[`child${this.type === "number" ? "Number" : ""}El`].value = newInputValue;
  328. };
  329. this.setPreviousEmittedValue = (newPreviousEmittedValue) => {
  330. this.previousEmittedValue =
  331. this.type === "number"
  332. ? isValidNumber(newPreviousEmittedValue)
  333. ? newPreviousEmittedValue
  334. : ""
  335. : newPreviousEmittedValue;
  336. };
  337. this.setPreviousValue = (newPreviousValue) => {
  338. this.previousValue =
  339. this.type === "number"
  340. ? isValidNumber(newPreviousValue)
  341. ? newPreviousValue
  342. : ""
  343. : newPreviousValue;
  344. };
  345. this.setValue = ({ committing = false, nativeEvent, origin, previousValue, value }) => {
  346. numberStringFormatter.numberFormatOptions = {
  347. locale: this.effectiveLocale,
  348. numberingSystem: this.numberingSystem,
  349. useGrouping: this.groupSeparator
  350. };
  351. if (this.type === "number") {
  352. const delocalizedValue = (this.numberingSystem && this.numberingSystem !== "latn") ||
  353. defaultNumberingSystem !== "latn"
  354. ? numberStringFormatter.delocalize(value)
  355. : value;
  356. const sanitizedValue = sanitizeNumberString(delocalizedValue);
  357. const newValue = (value && !sanitizedValue) || [".", "-"].includes(sanitizedValue)
  358. ? isValidNumber(this.previousValue)
  359. ? this.previousValue
  360. : ""
  361. : sanitizedValue;
  362. const newLocalizedValue = numberStringFormatter.localize(newValue);
  363. this.localizedValue = newLocalizedValue;
  364. this.userChangedValue = origin === "user" && this.value !== newValue;
  365. this.value = newValue;
  366. origin === "direct" && this.setInputValue(newLocalizedValue);
  367. }
  368. else {
  369. this.userChangedValue = origin === "user" && this.value !== value;
  370. this.value = value;
  371. origin === "direct" && this.setInputValue(value);
  372. }
  373. this.setPreviousValue(previousValue || this.value);
  374. this.previousValueOrigin = origin;
  375. if (nativeEvent) {
  376. const calciteInputInputEvent = this.calciteInputInput.emit({
  377. element: this.childEl,
  378. nativeEvent,
  379. value: this.value
  380. });
  381. if (calciteInputInputEvent.defaultPrevented) {
  382. this.value = this.previousValue;
  383. this.localizedValue =
  384. this.type === "number"
  385. ? numberStringFormatter.localize(this.previousValue)
  386. : this.previousValue;
  387. }
  388. else if (committing) {
  389. this.emitChangeIfUserModified();
  390. }
  391. }
  392. };
  393. this.inputKeyUpHandler = () => {
  394. window.clearInterval(this.nudgeNumberValueIntervalId);
  395. };
  396. }
  397. disabledWatcher() {
  398. this.setDisabledAction();
  399. }
  400. localeChanged() {
  401. updateEffectiveLocale(this);
  402. }
  403. /** watcher to update number-to-string for max */
  404. maxWatcher() {
  405. var _a;
  406. this.maxString = ((_a = this.max) === null || _a === void 0 ? void 0 : _a.toString()) || null;
  407. }
  408. /** watcher to update number-to-string for min */
  409. minWatcher() {
  410. var _a;
  411. this.minString = ((_a = this.min) === null || _a === void 0 ? void 0 : _a.toString()) || null;
  412. }
  413. valueWatcher(newValue, previousValue) {
  414. if (!this.userChangedValue) {
  415. this.setValue({
  416. origin: "direct",
  417. previousValue,
  418. value: newValue == null || newValue == ""
  419. ? ""
  420. : this.type === "number"
  421. ? isValidNumber(newValue)
  422. ? newValue
  423. : this.previousValue || ""
  424. : newValue
  425. });
  426. this.warnAboutInvalidNumberValue(newValue);
  427. }
  428. this.userChangedValue = false;
  429. }
  430. updateRequestedIcon() {
  431. this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type);
  432. }
  433. get isClearable() {
  434. return !this.isTextarea && (this.clearable || this.type === "search") && this.value.length > 0;
  435. }
  436. get isTextarea() {
  437. return this.childElType === "textarea";
  438. }
  439. //--------------------------------------------------------------------------
  440. //
  441. // Lifecycle
  442. //
  443. //--------------------------------------------------------------------------
  444. connectedCallback() {
  445. var _a;
  446. connectLocalized(this);
  447. this.scale = getElementProp(this.el, "scale", this.scale);
  448. this.status = getElementProp(this.el, "status", this.status);
  449. this.inlineEditableEl = this.el.closest("calcite-inline-editable");
  450. if (this.inlineEditableEl) {
  451. this.editingEnabled = this.inlineEditableEl.editingEnabled || false;
  452. }
  453. connectLabel(this);
  454. connectForm(this);
  455. this.setPreviousEmittedValue(this.value);
  456. this.setPreviousValue(this.value);
  457. if (this.type === "number") {
  458. this.warnAboutInvalidNumberValue(this.value);
  459. this.setValue({
  460. origin: "connected",
  461. value: isValidNumber(this.value) ? this.value : ""
  462. });
  463. }
  464. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
  465. this.setDisabledAction();
  466. this.el.addEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler);
  467. }
  468. disconnectedCallback() {
  469. var _a;
  470. disconnectLabel(this);
  471. disconnectForm(this);
  472. disconnectLocalized(this);
  473. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  474. this.el.removeEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler);
  475. }
  476. componentWillLoad() {
  477. var _a, _b;
  478. this.childElType = this.type === "textarea" ? "textarea" : "input";
  479. this.maxString = (_a = this.max) === null || _a === void 0 ? void 0 : _a.toString();
  480. this.minString = (_b = this.min) === null || _b === void 0 ? void 0 : _b.toString();
  481. this.requestedIcon = setRequestedIcon(INPUT_TYPE_ICONS, this.icon, this.type);
  482. }
  483. componentShouldUpdate(newValue, oldValue, property) {
  484. if (this.type === "number" && property === "value" && newValue && !isValidNumber(newValue)) {
  485. this.setValue({
  486. origin: "reset",
  487. value: oldValue
  488. });
  489. return false;
  490. }
  491. return true;
  492. }
  493. componentDidRender() {
  494. updateHostInteraction(this);
  495. }
  496. //--------------------------------------------------------------------------
  497. //
  498. // Public Methods
  499. //
  500. //--------------------------------------------------------------------------
  501. /** Sets focus on the component. */
  502. async setFocus() {
  503. var _a, _b;
  504. if (this.type === "number") {
  505. (_a = this.childNumberEl) === null || _a === void 0 ? void 0 : _a.focus();
  506. }
  507. else {
  508. (_b = this.childEl) === null || _b === void 0 ? void 0 : _b.focus();
  509. }
  510. }
  511. /** Selects all text of the component's `value`. */
  512. async selectText() {
  513. var _a, _b;
  514. if (this.type === "number") {
  515. (_a = this.childNumberEl) === null || _a === void 0 ? void 0 : _a.select();
  516. }
  517. else {
  518. (_b = this.childEl) === null || _b === void 0 ? void 0 : _b.select();
  519. }
  520. }
  521. onLabelClick() {
  522. this.setFocus();
  523. }
  524. incrementOrDecrementNumberValue(direction, inputMax, inputMin, nativeEvent) {
  525. const { value } = this;
  526. const inputStep = this.step === "any" ? 1 : Math.abs(this.step || 1);
  527. const inputVal = value && value !== "" ? parseFloat(value) : 0;
  528. const adjustment = direction === "up" ? 1 : -1;
  529. const nudgedValue = inputVal + inputStep * adjustment;
  530. const finalValue = (typeof inputMin === "number" && !isNaN(inputMin) && nudgedValue < inputMin) ||
  531. (typeof inputMax === "number" && !isNaN(inputMax) && nudgedValue > inputMax)
  532. ? inputVal
  533. : nudgedValue;
  534. const inputValPlaces = decimalPlaces(inputVal);
  535. const inputStepPlaces = decimalPlaces(inputStep);
  536. this.setValue({
  537. committing: true,
  538. nativeEvent,
  539. origin: "user",
  540. value: finalValue.toFixed(Math.max(inputValPlaces, inputStepPlaces))
  541. });
  542. }
  543. onFormReset() {
  544. this.setValue({
  545. origin: "reset",
  546. value: this.defaultValue
  547. });
  548. }
  549. syncHiddenFormInput(input) {
  550. var _a, _b, _c, _d;
  551. if (this.type === "number") {
  552. input.type = "number";
  553. input.min = (_b = (_a = this.min) === null || _a === void 0 ? void 0 : _a.toString(10)) !== null && _b !== void 0 ? _b : "";
  554. input.max = (_d = (_c = this.max) === null || _c === void 0 ? void 0 : _c.toString(10)) !== null && _d !== void 0 ? _d : "";
  555. }
  556. else if (this.type === "text") {
  557. input.type = "text";
  558. if (this.minLength != null) {
  559. input.minLength = this.minLength;
  560. }
  561. if (this.maxLength != null) {
  562. input.maxLength = this.maxLength;
  563. }
  564. }
  565. else if (this.type === "password") {
  566. input.type = "password";
  567. }
  568. }
  569. setDisabledAction() {
  570. const slottedActionEl = getSlotted(this.el, "action");
  571. if (!slottedActionEl) {
  572. return;
  573. }
  574. this.disabled
  575. ? slottedActionEl.setAttribute("disabled", "")
  576. : slottedActionEl.removeAttribute("disabled");
  577. }
  578. warnAboutInvalidNumberValue(value) {
  579. if (this.type === "number" && value && !isValidNumber(value)) {
  580. console.warn(`The specified value "${value}" cannot be parsed, or is out of range.`);
  581. }
  582. }
  583. // --------------------------------------------------------------------------
  584. //
  585. // Render Methods
  586. //
  587. // --------------------------------------------------------------------------
  588. render() {
  589. const dir = getElementDir(this.el);
  590. const loader = (h("div", { class: CSS.loader }, h("calcite-progress", { label: this.intlLoading, type: "indeterminate" })));
  591. 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" })));
  592. const iconEl = (h("calcite-icon", { class: CSS.inputIcon, flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: "s" }));
  593. const isHorizontalNumberButton = this.numberButtonType === "horizontal";
  594. const numberButtonsHorizontalUp = (h("button", { "aria-hidden": "true", class: {
  595. [CSS.numberButtonItem]: true,
  596. [CSS.buttonItemHorizontal]: isHorizontalNumberButton
  597. }, "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: "s" })));
  598. const numberButtonsHorizontalDown = (h("button", { "aria-hidden": "true", class: {
  599. [CSS.numberButtonItem]: true,
  600. [CSS.buttonItemHorizontal]: isHorizontalNumberButton
  601. }, "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: "s" })));
  602. const numberButtonsVertical = (h("div", { class: CSS.numberButtonWrapper }, numberButtonsHorizontalUp, numberButtonsHorizontalDown));
  603. const prefixText = h("div", { class: CSS.prefix }, this.prefixText);
  604. const suffixText = h("div", { class: CSS.suffix }, this.suffixText);
  605. const localeNumberInput = this.type === "number" ? (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.inputBlurHandler, onFocus: this.inputFocusHandler, onInput: this.inputNumberInputHandler, onKeyDown: this.inputNumberKeyDownHandler, onKeyUp: this.inputKeyUpHandler, placeholder: this.placeholder || "", readOnly: this.readOnly, ref: this.setChildNumberElRef, type: "text", value: this.localizedValue })) : null;
  606. const childEl = this.type !== "number"
  607. ? [
  608. h(this.childElType, { "aria-label": getLabelText(this), autofocus: this.autofocus ? true : null, class: {
  609. [CSS.editingEnabled]: this.editingEnabled,
  610. [CSS.inlineChild]: !!this.inlineEditableEl
  611. }, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.el.enterKeyHint, inputMode: this.el.inputMode, max: this.maxString, maxLength: this.maxLength, min: this.minString, minLength: this.minLength, name: this.name, onBlur: this.inputBlurHandler, onFocus: this.inputFocusHandler, onInput: this.inputInputHandler, onKeyDown: this.inputKeyDownHandler, onKeyUp: this.inputKeyUpHandler, placeholder: this.placeholder || "", readOnly: this.readOnly, ref: this.setChildElRef, required: this.required ? true : null, step: this.step, tabIndex: this.disabled || (this.inlineEditableEl && !this.editingEnabled) ? -1 : null, type: this.type, value: this.value }),
  612. this.isTextarea ? (h("div", { class: CSS.resizeIconWrapper }, h("calcite-icon", { icon: "chevron-down", scale: "s" }))) : null
  613. ]
  614. : null;
  615. return (h(Host, { onClick: this.inputFocusHandler, onKeyDown: this.keyDownHandler }, h("div", { class: { [CSS.inputWrapper]: true, [CSS_UTILITY.rtl]: dir === "rtl" } }, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly
  616. ? numberButtonsHorizontalDown
  617. : 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
  618. ? numberButtonsVertical
  619. : null, this.suffixText ? suffixText : null, this.type === "number" && this.numberButtonType === "horizontal" && !this.readOnly
  620. ? numberButtonsHorizontalUp
  621. : null, h(HiddenFormInputSlot, { component: this }))));
  622. }
  623. static get is() { return "calcite-input"; }
  624. static get encapsulation() { return "shadow"; }
  625. static get originalStyleUrls() {
  626. return {
  627. "$": ["input.scss"]
  628. };
  629. }
  630. static get styleUrls() {
  631. return {
  632. "$": ["input.css"]
  633. };
  634. }
  635. static get properties() {
  636. return {
  637. "alignment": {
  638. "type": "string",
  639. "mutable": false,
  640. "complexType": {
  641. "original": "Position",
  642. "resolved": "\"end\" | \"start\"",
  643. "references": {
  644. "Position": {
  645. "location": "import",
  646. "path": "../interfaces"
  647. }
  648. }
  649. },
  650. "required": false,
  651. "optional": false,
  652. "docs": {
  653. "tags": [],
  654. "text": "Specifies the text alignment of the component's value."
  655. },
  656. "attribute": "alignment",
  657. "reflect": true,
  658. "defaultValue": "\"start\""
  659. },
  660. "autofocus": {
  661. "type": "boolean",
  662. "mutable": false,
  663. "complexType": {
  664. "original": "boolean",
  665. "resolved": "boolean",
  666. "references": {}
  667. },
  668. "required": false,
  669. "optional": false,
  670. "docs": {
  671. "tags": [{
  672. "name": "mdn",
  673. "text": "[autofocus](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus)"
  674. }],
  675. "text": "When `true`, the component is focused on page load."
  676. },
  677. "attribute": "autofocus",
  678. "reflect": true,
  679. "defaultValue": "false"
  680. },
  681. "clearable": {
  682. "type": "boolean",
  683. "mutable": false,
  684. "complexType": {
  685. "original": "boolean",
  686. "resolved": "boolean",
  687. "references": {}
  688. },
  689. "required": false,
  690. "optional": false,
  691. "docs": {
  692. "tags": [],
  693. "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."
  694. },
  695. "attribute": "clearable",
  696. "reflect": true,
  697. "defaultValue": "false"
  698. },
  699. "disabled": {
  700. "type": "boolean",
  701. "mutable": false,
  702. "complexType": {
  703. "original": "boolean",
  704. "resolved": "boolean",
  705. "references": {}
  706. },
  707. "required": false,
  708. "optional": false,
  709. "docs": {
  710. "tags": [{
  711. "name": "mdn",
  712. "text": "[disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled)"
  713. }],
  714. "text": "When `true`, interaction is prevented and the component is displayed with lower opacity."
  715. },
  716. "attribute": "disabled",
  717. "reflect": true,
  718. "defaultValue": "false"
  719. },
  720. "groupSeparator": {
  721. "type": "boolean",
  722. "mutable": false,
  723. "complexType": {
  724. "original": "boolean",
  725. "resolved": "boolean",
  726. "references": {}
  727. },
  728. "required": false,
  729. "optional": false,
  730. "docs": {
  731. "tags": [],
  732. "text": "When `true`, number values are displayed with a group separator corresponding to the language and country format."
  733. },
  734. "attribute": "group-separator",
  735. "reflect": true,
  736. "defaultValue": "false"
  737. },
  738. "hidden": {
  739. "type": "boolean",
  740. "mutable": false,
  741. "complexType": {
  742. "original": "boolean",
  743. "resolved": "boolean",
  744. "references": {}
  745. },
  746. "required": false,
  747. "optional": false,
  748. "docs": {
  749. "tags": [{
  750. "name": "mdn",
  751. "text": "[hidden](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden)"
  752. }],
  753. "text": "When `true`, the component will not be visible."
  754. },
  755. "attribute": "hidden",
  756. "reflect": true,
  757. "defaultValue": "false"
  758. },
  759. "icon": {
  760. "type": "any",
  761. "mutable": false,
  762. "complexType": {
  763. "original": "string | boolean",
  764. "resolved": "boolean | string",
  765. "references": {}
  766. },
  767. "required": false,
  768. "optional": false,
  769. "docs": {
  770. "tags": [],
  771. "text": "When `true`, shows a default recommended icon. Alternatively, pass a Calcite UI Icon name to display a specific icon."
  772. },
  773. "attribute": "icon",
  774. "reflect": true
  775. },
  776. "intlClear": {
  777. "type": "string",
  778. "mutable": false,
  779. "complexType": {
  780. "original": "string",
  781. "resolved": "string",
  782. "references": {}
  783. },
  784. "required": false,
  785. "optional": true,
  786. "docs": {
  787. "tags": [],
  788. "text": "Accessible name for the component's clear button."
  789. },
  790. "attribute": "intl-clear",
  791. "reflect": false
  792. },
  793. "intlLoading": {
  794. "type": "string",
  795. "mutable": false,
  796. "complexType": {
  797. "original": "string",
  798. "resolved": "string",
  799. "references": {}
  800. },
  801. "required": false,
  802. "optional": true,
  803. "docs": {
  804. "tags": [{
  805. "name": "default",
  806. "text": "\"Loading\""
  807. }],
  808. "text": "Accessible name when the component is loading."
  809. },
  810. "attribute": "intl-loading",
  811. "reflect": false,
  812. "defaultValue": "COMMON_TEXT.loading"
  813. },
  814. "iconFlipRtl": {
  815. "type": "boolean",
  816. "mutable": false,
  817. "complexType": {
  818. "original": "boolean",
  819. "resolved": "boolean",
  820. "references": {}
  821. },
  822. "required": false,
  823. "optional": false,
  824. "docs": {
  825. "tags": [],
  826. "text": "When `true`, the icon will be flipped when the element direction is right-to-left (`\"rtl\"`)."
  827. },
  828. "attribute": "icon-flip-rtl",
  829. "reflect": true,
  830. "defaultValue": "false"
  831. },
  832. "label": {
  833. "type": "string",
  834. "mutable": false,
  835. "complexType": {
  836. "original": "string",
  837. "resolved": "string",
  838. "references": {}
  839. },
  840. "required": false,
  841. "optional": true,
  842. "docs": {
  843. "tags": [],
  844. "text": "Accessible name for the component."
  845. },
  846. "attribute": "label",
  847. "reflect": false
  848. },
  849. "loading": {
  850. "type": "boolean",
  851. "mutable": false,
  852. "complexType": {
  853. "original": "boolean",
  854. "resolved": "boolean",
  855. "references": {}
  856. },
  857. "required": false,
  858. "optional": false,
  859. "docs": {
  860. "tags": [],
  861. "text": "When `true`, a busy indicator is displayed."
  862. },
  863. "attribute": "loading",
  864. "reflect": true,
  865. "defaultValue": "false"
  866. },
  867. "locale": {
  868. "type": "string",
  869. "mutable": false,
  870. "complexType": {
  871. "original": "string",
  872. "resolved": "string",
  873. "references": {}
  874. },
  875. "required": false,
  876. "optional": false,
  877. "docs": {
  878. "tags": [{
  879. "name": "deprecated",
  880. "text": "set the global `lang` attribute on the element instead."
  881. }, {
  882. "name": "mdn",
  883. "text": "[lang](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)"
  884. }],
  885. "text": "BCP 47 language tag for desired language and country format"
  886. },
  887. "attribute": "locale",
  888. "reflect": false
  889. },
  890. "numberingSystem": {
  891. "type": "string",
  892. "mutable": false,
  893. "complexType": {
  894. "original": "NumberingSystem",
  895. "resolved": "\"arab\" | \"arabext\" | \"bali\" | \"beng\" | \"deva\" | \"fullwide\" | \"gujr\" | \"guru\" | \"hanidec\" | \"khmr\" | \"knda\" | \"laoo\" | \"latn\" | \"limb\" | \"mlym\" | \"mong\" | \"mymr\" | \"orya\" | \"tamldec\" | \"telu\" | \"thai\" | \"tibt\"",
  896. "references": {
  897. "NumberingSystem": {
  898. "location": "import",
  899. "path": "../../utils/locale"
  900. }
  901. }
  902. },
  903. "required": false,
  904. "optional": true,
  905. "docs": {
  906. "tags": [],
  907. "text": "Specifies the Unicode numeral system used by the component for localization."
  908. },
  909. "attribute": "numbering-system",
  910. "reflect": true
  911. },
  912. "localeFormat": {
  913. "type": "boolean",
  914. "mutable": false,
  915. "complexType": {
  916. "original": "boolean",
  917. "resolved": "boolean",
  918. "references": {}
  919. },
  920. "required": false,
  921. "optional": false,
  922. "docs": {
  923. "tags": [{
  924. "name": "internal",
  925. "text": undefined
  926. }],
  927. "text": "When `true`, uses locale formatting for numbers."
  928. },
  929. "attribute": "locale-format",
  930. "reflect": false,
  931. "defaultValue": "false"
  932. },
  933. "max": {
  934. "type": "number",
  935. "mutable": false,
  936. "complexType": {
  937. "original": "number",
  938. "resolved": "number",
  939. "references": {}
  940. },
  941. "required": false,
  942. "optional": true,
  943. "docs": {
  944. "tags": [{
  945. "name": "mdn",
  946. "text": "[max](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max)"
  947. }],
  948. "text": "Specifies the maximum value for type \"number\"."
  949. },
  950. "attribute": "max",
  951. "reflect": true
  952. },
  953. "min": {
  954. "type": "number",
  955. "mutable": false,
  956. "complexType": {
  957. "original": "number",
  958. "resolved": "number",
  959. "references": {}
  960. },
  961. "required": false,
  962. "optional": true,
  963. "docs": {
  964. "tags": [{
  965. "name": "mdn",
  966. "text": "[min](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min)"
  967. }],
  968. "text": "Specifies the minimum value for `type=\"number\"`."
  969. },
  970. "attribute": "min",
  971. "reflect": true
  972. },
  973. "maxlength": {
  974. "type": "number",
  975. "mutable": false,
  976. "complexType": {
  977. "original": "number",
  978. "resolved": "number",
  979. "references": {}
  980. },
  981. "required": false,
  982. "optional": true,
  983. "docs": {
  984. "tags": [{
  985. "name": "deprecated",
  986. "text": "use `maxLength` instead."
  987. }],
  988. "text": "Specifies the maximum length of text for the component's value."
  989. },
  990. "attribute": "maxlength",
  991. "reflect": true
  992. },
  993. "maxLength": {
  994. "type": "number",
  995. "mutable": false,
  996. "complexType": {
  997. "original": "number",
  998. "resolved": "number",
  999. "references": {}
  1000. },
  1001. "required": false,
  1002. "optional": true,
  1003. "docs": {
  1004. "tags": [{
  1005. "name": "mdn",
  1006. "text": "[maxlength](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength)"
  1007. }],
  1008. "text": "Specifies the maximum length of text for the component's value."
  1009. },
  1010. "attribute": "max-length",
  1011. "reflect": true
  1012. },
  1013. "minLength": {
  1014. "type": "number",
  1015. "mutable": false,
  1016. "complexType": {
  1017. "original": "number",
  1018. "resolved": "number",
  1019. "references": {}
  1020. },
  1021. "required": false,
  1022. "optional": true,
  1023. "docs": {
  1024. "tags": [{
  1025. "name": "mdn",
  1026. "text": "[minlength](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength)"
  1027. }],
  1028. "text": "Specifies the minimum length of text for the component's value."
  1029. },
  1030. "attribute": "min-length",
  1031. "reflect": true
  1032. },
  1033. "name": {
  1034. "type": "string",
  1035. "mutable": false,
  1036. "complexType": {
  1037. "original": "string",
  1038. "resolved": "string",
  1039. "references": {}
  1040. },
  1041. "required": false,
  1042. "optional": false,
  1043. "docs": {
  1044. "tags": [{
  1045. "name": "mdn",
  1046. "text": "[name](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name)"
  1047. }],
  1048. "text": "Specifies the name of the component on form submission."
  1049. },
  1050. "attribute": "name",
  1051. "reflect": true
  1052. },
  1053. "numberButtonType": {
  1054. "type": "string",
  1055. "mutable": false,
  1056. "complexType": {
  1057. "original": "InputPlacement",
  1058. "resolved": "\"horizontal\" | \"none\" | \"vertical\"",
  1059. "references": {
  1060. "InputPlacement": {
  1061. "location": "import",
  1062. "path": "./interfaces"
  1063. }
  1064. }
  1065. },
  1066. "required": false,
  1067. "optional": true,
  1068. "docs": {
  1069. "tags": [],
  1070. "text": "Specifies the placement of the buttons for `type=\"number\"`."
  1071. },
  1072. "attribute": "number-button-type",
  1073. "reflect": true,
  1074. "defaultValue": "\"vertical\""
  1075. },
  1076. "placeholder": {
  1077. "type": "string",
  1078. "mutable": false,
  1079. "complexType": {
  1080. "original": "string",
  1081. "resolved": "string",
  1082. "references": {}
  1083. },
  1084. "required": false,
  1085. "optional": false,
  1086. "docs": {
  1087. "tags": [{
  1088. "name": "mdn",
  1089. "text": "[placeholder](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder)"
  1090. }],
  1091. "text": "Specifies placeholder text for the component."
  1092. },
  1093. "attribute": "placeholder",
  1094. "reflect": false
  1095. },
  1096. "prefixText": {
  1097. "type": "string",
  1098. "mutable": false,
  1099. "complexType": {
  1100. "original": "string",
  1101. "resolved": "string",
  1102. "references": {}
  1103. },
  1104. "required": false,
  1105. "optional": true,
  1106. "docs": {
  1107. "tags": [],
  1108. "text": "Adds text to the start of the component."
  1109. },
  1110. "attribute": "prefix-text",
  1111. "reflect": false
  1112. },
  1113. "readOnly": {
  1114. "type": "boolean",
  1115. "mutable": false,
  1116. "complexType": {
  1117. "original": "boolean",
  1118. "resolved": "boolean",
  1119. "references": {}
  1120. },
  1121. "required": false,
  1122. "optional": false,
  1123. "docs": {
  1124. "tags": [{
  1125. "name": "mdn",
  1126. "text": "[readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)"
  1127. }],
  1128. "text": "When `true`, the component's value can be read, but cannot be modified."
  1129. },
  1130. "attribute": "read-only",
  1131. "reflect": true,
  1132. "defaultValue": "false"
  1133. },
  1134. "required": {
  1135. "type": "boolean",
  1136. "mutable": false,
  1137. "complexType": {
  1138. "original": "boolean",
  1139. "resolved": "boolean",
  1140. "references": {}
  1141. },
  1142. "required": false,
  1143. "optional": false,
  1144. "docs": {
  1145. "tags": [],
  1146. "text": "When `true`, the component must have a value in order for the form to submit."
  1147. },
  1148. "attribute": "required",
  1149. "reflect": true,
  1150. "defaultValue": "false"
  1151. },
  1152. "scale": {
  1153. "type": "string",
  1154. "mutable": true,
  1155. "complexType": {
  1156. "original": "Scale",
  1157. "resolved": "\"l\" | \"m\" | \"s\"",
  1158. "references": {
  1159. "Scale": {
  1160. "location": "import",
  1161. "path": "../interfaces"
  1162. }
  1163. }
  1164. },
  1165. "required": false,
  1166. "optional": false,
  1167. "docs": {
  1168. "tags": [],
  1169. "text": "Specifies the size of the component."
  1170. },
  1171. "attribute": "scale",
  1172. "reflect": true,
  1173. "defaultValue": "\"m\""
  1174. },
  1175. "status": {
  1176. "type": "string",
  1177. "mutable": true,
  1178. "complexType": {
  1179. "original": "Status",
  1180. "resolved": "\"idle\" | \"invalid\" | \"valid\"",
  1181. "references": {
  1182. "Status": {
  1183. "location": "import",
  1184. "path": "../interfaces"
  1185. }
  1186. }
  1187. },
  1188. "required": false,
  1189. "optional": false,
  1190. "docs": {
  1191. "tags": [],
  1192. "text": "Specifies the status of the input field, which determines message and icons."
  1193. },
  1194. "attribute": "status",
  1195. "reflect": true,
  1196. "defaultValue": "\"idle\""
  1197. },
  1198. "step": {
  1199. "type": "any",
  1200. "mutable": false,
  1201. "complexType": {
  1202. "original": "number | \"any\"",
  1203. "resolved": "\"any\" | number",
  1204. "references": {}
  1205. },
  1206. "required": false,
  1207. "optional": true,
  1208. "docs": {
  1209. "tags": [{
  1210. "name": "mdn",
  1211. "text": "[step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step)"
  1212. }],
  1213. "text": "Specifies the granularity the component's value must adhere to."
  1214. },
  1215. "attribute": "step",
  1216. "reflect": true
  1217. },
  1218. "suffixText": {
  1219. "type": "string",
  1220. "mutable": false,
  1221. "complexType": {
  1222. "original": "string",
  1223. "resolved": "string",
  1224. "references": {}
  1225. },
  1226. "required": false,
  1227. "optional": true,
  1228. "docs": {
  1229. "tags": [],
  1230. "text": "Adds text to the end of the component."
  1231. },
  1232. "attribute": "suffix-text",
  1233. "reflect": false
  1234. },
  1235. "editingEnabled": {
  1236. "type": "boolean",
  1237. "mutable": true,
  1238. "complexType": {
  1239. "original": "boolean",
  1240. "resolved": "boolean",
  1241. "references": {}
  1242. },
  1243. "required": false,
  1244. "optional": false,
  1245. "docs": {
  1246. "tags": [{
  1247. "name": "internal",
  1248. "text": undefined
  1249. }],
  1250. "text": ""
  1251. },
  1252. "attribute": "editing-enabled",
  1253. "reflect": true,
  1254. "defaultValue": "false"
  1255. },
  1256. "type": {
  1257. "type": "string",
  1258. "mutable": false,
  1259. "complexType": {
  1260. "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\"",
  1261. "resolved": "\"color\" | \"date\" | \"datetime-local\" | \"email\" | \"file\" | \"image\" | \"month\" | \"number\" | \"password\" | \"search\" | \"tel\" | \"text\" | \"textarea\" | \"time\" | \"url\" | \"week\"",
  1262. "references": {}
  1263. },
  1264. "required": false,
  1265. "optional": false,
  1266. "docs": {
  1267. "tags": [],
  1268. "text": "Specifies the component type.\n\nNote that the following `type`s add type-specific icons by default: `\"date\"`, `\"email\"`, `\"password\"`, `\"search\"`, `\"tel\"`, `\"time\"`."
  1269. },
  1270. "attribute": "type",
  1271. "reflect": true,
  1272. "defaultValue": "\"text\""
  1273. },
  1274. "value": {
  1275. "type": "string",
  1276. "mutable": true,
  1277. "complexType": {
  1278. "original": "string",
  1279. "resolved": "string",
  1280. "references": {}
  1281. },
  1282. "required": false,
  1283. "optional": false,
  1284. "docs": {
  1285. "tags": [],
  1286. "text": "The component's value."
  1287. },
  1288. "attribute": "value",
  1289. "reflect": false,
  1290. "defaultValue": "\"\""
  1291. }
  1292. };
  1293. }
  1294. static get states() {
  1295. return {
  1296. "effectiveLocale": {},
  1297. "localizedValue": {}
  1298. };
  1299. }
  1300. static get events() {
  1301. return [{
  1302. "method": "calciteInternalInputFocus",
  1303. "name": "calciteInternalInputFocus",
  1304. "bubbles": true,
  1305. "cancelable": false,
  1306. "composed": true,
  1307. "docs": {
  1308. "tags": [{
  1309. "name": "internal",
  1310. "text": undefined
  1311. }],
  1312. "text": ""
  1313. },
  1314. "complexType": {
  1315. "original": "void",
  1316. "resolved": "void",
  1317. "references": {}
  1318. }
  1319. }, {
  1320. "method": "calciteInternalInputBlur",
  1321. "name": "calciteInternalInputBlur",
  1322. "bubbles": true,
  1323. "cancelable": false,
  1324. "composed": true,
  1325. "docs": {
  1326. "tags": [{
  1327. "name": "internal",
  1328. "text": undefined
  1329. }],
  1330. "text": ""
  1331. },
  1332. "complexType": {
  1333. "original": "void",
  1334. "resolved": "void",
  1335. "references": {}
  1336. }
  1337. }, {
  1338. "method": "calciteInputInput",
  1339. "name": "calciteInputInput",
  1340. "bubbles": true,
  1341. "cancelable": true,
  1342. "composed": true,
  1343. "docs": {
  1344. "tags": [],
  1345. "text": "Fires each time a new `value` is typed.\n\n**Note:**: The `el` and `value` event payload properties are deprecated, use the event's `target`/`currentTarget` instead."
  1346. },
  1347. "complexType": {
  1348. "original": "DeprecatedEventPayload",
  1349. "resolved": "any",
  1350. "references": {
  1351. "DeprecatedEventPayload": {
  1352. "location": "import",
  1353. "path": "../interfaces"
  1354. }
  1355. }
  1356. }
  1357. }, {
  1358. "method": "calciteInputChange",
  1359. "name": "calciteInputChange",
  1360. "bubbles": true,
  1361. "cancelable": false,
  1362. "composed": true,
  1363. "docs": {
  1364. "tags": [],
  1365. "text": "Fires each time a new `value` is typed and committed."
  1366. },
  1367. "complexType": {
  1368. "original": "void",
  1369. "resolved": "void",
  1370. "references": {}
  1371. }
  1372. }];
  1373. }
  1374. static get methods() {
  1375. return {
  1376. "setFocus": {
  1377. "complexType": {
  1378. "signature": "() => Promise<void>",
  1379. "parameters": [],
  1380. "references": {
  1381. "Promise": {
  1382. "location": "global"
  1383. }
  1384. },
  1385. "return": "Promise<void>"
  1386. },
  1387. "docs": {
  1388. "text": "Sets focus on the component.",
  1389. "tags": []
  1390. }
  1391. },
  1392. "selectText": {
  1393. "complexType": {
  1394. "signature": "() => Promise<void>",
  1395. "parameters": [],
  1396. "references": {
  1397. "Promise": {
  1398. "location": "global"
  1399. }
  1400. },
  1401. "return": "Promise<void>"
  1402. },
  1403. "docs": {
  1404. "text": "Selects all text of the component's `value`.",
  1405. "tags": []
  1406. }
  1407. }
  1408. };
  1409. }
  1410. static get elementRef() { return "el"; }
  1411. static get watchers() {
  1412. return [{
  1413. "propName": "disabled",
  1414. "methodName": "disabledWatcher"
  1415. }, {
  1416. "propName": "locale",
  1417. "methodName": "localeChanged"
  1418. }, {
  1419. "propName": "max",
  1420. "methodName": "maxWatcher"
  1421. }, {
  1422. "propName": "min",
  1423. "methodName": "minWatcher"
  1424. }, {
  1425. "propName": "value",
  1426. "methodName": "valueWatcher"
  1427. }, {
  1428. "propName": "icon",
  1429. "methodName": "updateRequestedIcon"
  1430. }, {
  1431. "propName": "type",
  1432. "methodName": "updateRequestedIcon"
  1433. }];
  1434. }
  1435. }