input-text.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  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, setRequestedIcon } from "../../utils/dom";
  8. import { CSS, SLOTS, TEXT } from "./resources";
  9. import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label";
  10. import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form";
  11. import { CSS_UTILITY, TEXT as COMMON_TEXT } from "../../utils/resources";
  12. import { createObserver } from "../../utils/observers";
  13. import { updateHostInteraction } from "../../utils/interactive";
  14. /**
  15. * @slot action - A slot for positioning a button next to the component.
  16. */
  17. export class InputText {
  18. constructor() {
  19. //--------------------------------------------------------------------------
  20. //
  21. // Properties
  22. //
  23. //--------------------------------------------------------------------------
  24. /** Specifies the text alignment of the component's value. */
  25. this.alignment = "start";
  26. /**
  27. * When `true`, the component is focused on page load.
  28. *
  29. * @mdn [autofocus](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus)
  30. */
  31. this.autofocus = false;
  32. /**
  33. * When `true`, a clear button is displayed when the component has a value.
  34. */
  35. this.clearable = false;
  36. /**
  37. * When `true`, interaction is prevented and the component is displayed with lower opacity.
  38. *
  39. * @mdn [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled)
  40. */
  41. this.disabled = false;
  42. /**
  43. * When `true`, the component will not be visible.
  44. *
  45. * @mdn [hidden](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden)
  46. */
  47. this.hidden = false;
  48. /**
  49. * Accessible name that will appear while loading.
  50. *
  51. * @default "Loading"
  52. */
  53. this.intlLoading = COMMON_TEXT.loading;
  54. /** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
  55. this.iconFlipRtl = false;
  56. /** When `true`, the component is in the loading state and `calcite-progress` is displayed. */
  57. this.loading = false;
  58. /**
  59. * When `true`, the component's value can be read, but cannot be modified.
  60. *
  61. * @mdn [readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)
  62. */
  63. this.readOnly = false;
  64. /** When `true`, the component must have a value in order for the form to submit. */
  65. this.required = false;
  66. /** Specifies the size of the component. */
  67. this.scale = "m";
  68. /** Specifies the status of the input field, which determines message and icons. */
  69. this.status = "idle";
  70. /**
  71. * @internal
  72. */
  73. this.editingEnabled = false;
  74. /** The component's value. */
  75. this.value = "";
  76. this.previousValueOrigin = "initial";
  77. this.mutationObserver = createObserver("mutation", () => this.setDisabledAction());
  78. this.userChangedValue = false;
  79. //--------------------------------------------------------------------------
  80. //
  81. // Private Methods
  82. //
  83. //--------------------------------------------------------------------------
  84. this.keyDownHandler = (event) => {
  85. if (this.readOnly || this.disabled) {
  86. return;
  87. }
  88. if (this.isClearable && event.key === "Escape") {
  89. this.clearInputTextValue(event);
  90. event.preventDefault();
  91. }
  92. if (event.key === "Enter" && !event.defaultPrevented) {
  93. if (submitForm(this)) {
  94. event.preventDefault();
  95. }
  96. }
  97. };
  98. this.clearInputTextValue = (nativeEvent) => {
  99. this.setValue({
  100. committing: true,
  101. nativeEvent,
  102. origin: "user",
  103. value: ""
  104. });
  105. };
  106. this.emitChangeIfUserModified = () => {
  107. if (this.previousValueOrigin === "user" && this.value !== this.previousEmittedValue) {
  108. this.calciteInputTextChange.emit();
  109. }
  110. this.previousEmittedValue = this.value;
  111. };
  112. this.inputTextBlurHandler = () => {
  113. this.calciteInternalInputTextBlur.emit({
  114. element: this.childEl,
  115. value: this.value
  116. });
  117. this.emitChangeIfUserModified();
  118. };
  119. this.inputTextFocusHandler = (event) => {
  120. const slottedActionEl = getSlotted(this.el, "action");
  121. if (event.target !== slottedActionEl) {
  122. this.setFocus();
  123. }
  124. this.calciteInternalInputTextFocus.emit({
  125. element: this.childEl,
  126. value: this.value
  127. });
  128. };
  129. this.inputTextInputHandler = (nativeEvent) => {
  130. if (this.disabled || this.readOnly) {
  131. return;
  132. }
  133. this.setValue({
  134. nativeEvent,
  135. origin: "user",
  136. value: nativeEvent.target.value
  137. });
  138. };
  139. this.inputTextKeyDownHandler = (event) => {
  140. if (this.disabled || this.readOnly) {
  141. return;
  142. }
  143. if (event.key === "Enter") {
  144. this.emitChangeIfUserModified();
  145. }
  146. };
  147. this.hiddenInputChangeHandler = (event) => {
  148. if (event.target.name === this.name) {
  149. this.setValue({
  150. value: event.target.value,
  151. origin: "direct"
  152. });
  153. }
  154. event.stopPropagation();
  155. };
  156. this.setChildElRef = (el) => {
  157. this.childEl = el;
  158. };
  159. this.setInputValue = (newInputValue) => {
  160. if (!this.childEl) {
  161. return;
  162. }
  163. this.childEl.value = newInputValue;
  164. };
  165. this.setPreviousEmittedValue = (newPreviousEmittedValue) => {
  166. this.previousEmittedValue = newPreviousEmittedValue;
  167. };
  168. this.setPreviousValue = (newPreviousValue) => {
  169. this.previousValue = newPreviousValue;
  170. };
  171. this.setValue = ({ committing = false, nativeEvent, origin, previousValue, value }) => {
  172. this.setPreviousValue(previousValue || this.value);
  173. this.previousValueOrigin = origin;
  174. this.userChangedValue = origin === "user" && value !== this.value;
  175. this.value = value;
  176. if (origin === "direct") {
  177. this.setInputValue(value);
  178. }
  179. if (nativeEvent) {
  180. const calciteInputTextInputEvent = this.calciteInputTextInput.emit({
  181. element: this.childEl,
  182. nativeEvent,
  183. value: this.value
  184. });
  185. if (calciteInputTextInputEvent.defaultPrevented) {
  186. this.value = this.previousValue;
  187. }
  188. else if (committing) {
  189. this.emitChangeIfUserModified();
  190. }
  191. }
  192. };
  193. }
  194. disabledWatcher() {
  195. this.setDisabledAction();
  196. }
  197. valueWatcher(newValue, previousValue) {
  198. if (!this.userChangedValue) {
  199. this.setValue({
  200. origin: "direct",
  201. previousValue,
  202. value: !newValue ? "" : newValue
  203. });
  204. }
  205. this.userChangedValue = false;
  206. }
  207. updateRequestedIcon() {
  208. this.requestedIcon = setRequestedIcon({}, this.icon, "text");
  209. }
  210. get isClearable() {
  211. return this.clearable && this.value.length > 0;
  212. }
  213. //--------------------------------------------------------------------------
  214. //
  215. // Lifecycle
  216. //
  217. //--------------------------------------------------------------------------
  218. connectedCallback() {
  219. var _a;
  220. this.scale = getElementProp(this.el, "scale", this.scale);
  221. this.status = getElementProp(this.el, "status", this.status);
  222. this.inlineEditableEl = this.el.closest("calcite-inline-editable");
  223. if (this.inlineEditableEl) {
  224. this.editingEnabled = this.inlineEditableEl.editingEnabled || false;
  225. }
  226. this.setPreviousEmittedValue(this.value);
  227. this.setPreviousValue(this.value);
  228. connectLabel(this);
  229. connectForm(this);
  230. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
  231. this.setDisabledAction();
  232. this.el.addEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler);
  233. }
  234. disconnectedCallback() {
  235. var _a;
  236. disconnectLabel(this);
  237. disconnectForm(this);
  238. (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
  239. this.el.removeEventListener("calciteInternalHiddenInputChange", this.hiddenInputChangeHandler);
  240. }
  241. componentWillLoad() {
  242. this.requestedIcon = setRequestedIcon({}, this.icon, "text");
  243. }
  244. componentDidRender() {
  245. updateHostInteraction(this);
  246. }
  247. //--------------------------------------------------------------------------
  248. //
  249. // Public Methods
  250. //
  251. //--------------------------------------------------------------------------
  252. /** Sets focus on the component. */
  253. async setFocus() {
  254. var _a;
  255. (_a = this.childEl) === null || _a === void 0 ? void 0 : _a.focus();
  256. }
  257. /** Selects all text of the component's `value`. */
  258. async selectText() {
  259. var _a;
  260. (_a = this.childEl) === null || _a === void 0 ? void 0 : _a.select();
  261. }
  262. onLabelClick() {
  263. this.setFocus();
  264. }
  265. onFormReset() {
  266. this.setValue({
  267. origin: "reset",
  268. value: this.defaultValue
  269. });
  270. }
  271. syncHiddenFormInput(input) {
  272. if (this.minLength != null) {
  273. input.minLength = this.minLength;
  274. }
  275. if (this.maxLength != null) {
  276. input.maxLength = this.maxLength;
  277. }
  278. }
  279. setDisabledAction() {
  280. const slottedActionEl = getSlotted(this.el, "action");
  281. if (!slottedActionEl) {
  282. return;
  283. }
  284. this.disabled
  285. ? slottedActionEl.setAttribute("disabled", "")
  286. : slottedActionEl.removeAttribute("disabled");
  287. }
  288. // --------------------------------------------------------------------------
  289. //
  290. // Render Methods
  291. //
  292. // --------------------------------------------------------------------------
  293. render() {
  294. const dir = getElementDir(this.el);
  295. const loader = (h("div", { class: CSS.loader }, h("calcite-progress", { label: this.intlLoading, type: "indeterminate" })));
  296. const inputClearButton = (h("button", { "aria-label": this.intlClear || TEXT.clear, class: CSS.clearButton, disabled: this.disabled || this.readOnly, onClick: this.clearInputTextValue, tabIndex: -1, type: "button" }, h("calcite-icon", { icon: "x", scale: "s" })));
  297. const iconEl = (h("calcite-icon", { class: CSS.inputIcon, flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: "s" }));
  298. const prefixText = h("div", { class: CSS.prefix }, this.prefixText);
  299. const suffixText = h("div", { class: CSS.suffix }, this.suffixText);
  300. const childEl = (h("input", { "aria-label": getLabelText(this), autofocus: this.autofocus ? true : null, class: {
  301. [CSS.editingEnabled]: this.editingEnabled,
  302. [CSS.inlineChild]: !!this.inlineEditableEl
  303. }, defaultValue: this.defaultValue, disabled: this.disabled ? true : null, enterKeyHint: this.el.enterKeyHint, inputMode: this.el.inputMode, maxLength: this.maxLength, minLength: this.minLength, name: this.name, onBlur: this.inputTextBlurHandler, onFocus: this.inputTextFocusHandler, onInput: this.inputTextInputHandler, onKeyDown: this.inputTextKeyDownHandler, placeholder: this.placeholder || "", readOnly: this.readOnly, ref: this.setChildElRef, required: this.required ? true : null, tabIndex: this.disabled || (this.inlineEditableEl && !this.editingEnabled) ? -1 : null, type: "text", value: this.value }));
  304. return (h(Host, { onClick: this.inputTextFocusHandler, onKeyDown: this.keyDownHandler }, h("div", { class: { [CSS.inputWrapper]: true, [CSS_UTILITY.rtl]: dir === "rtl" } }, 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.suffixText ? suffixText : null, h(HiddenFormInputSlot, { component: this }))));
  305. }
  306. static get is() { return "calcite-input-text"; }
  307. static get encapsulation() { return "shadow"; }
  308. static get originalStyleUrls() {
  309. return {
  310. "$": ["input-text.scss"]
  311. };
  312. }
  313. static get styleUrls() {
  314. return {
  315. "$": ["input-text.css"]
  316. };
  317. }
  318. static get properties() {
  319. return {
  320. "alignment": {
  321. "type": "string",
  322. "mutable": false,
  323. "complexType": {
  324. "original": "Position",
  325. "resolved": "\"end\" | \"start\"",
  326. "references": {
  327. "Position": {
  328. "location": "import",
  329. "path": "../interfaces"
  330. }
  331. }
  332. },
  333. "required": false,
  334. "optional": false,
  335. "docs": {
  336. "tags": [],
  337. "text": "Specifies the text alignment of the component's value."
  338. },
  339. "attribute": "alignment",
  340. "reflect": true,
  341. "defaultValue": "\"start\""
  342. },
  343. "autofocus": {
  344. "type": "boolean",
  345. "mutable": false,
  346. "complexType": {
  347. "original": "boolean",
  348. "resolved": "boolean",
  349. "references": {}
  350. },
  351. "required": false,
  352. "optional": false,
  353. "docs": {
  354. "tags": [{
  355. "name": "mdn",
  356. "text": "[autofocus](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus)"
  357. }],
  358. "text": "When `true`, the component is focused on page load."
  359. },
  360. "attribute": "autofocus",
  361. "reflect": true,
  362. "defaultValue": "false"
  363. },
  364. "clearable": {
  365. "type": "boolean",
  366. "mutable": false,
  367. "complexType": {
  368. "original": "boolean",
  369. "resolved": "boolean",
  370. "references": {}
  371. },
  372. "required": false,
  373. "optional": false,
  374. "docs": {
  375. "tags": [],
  376. "text": "When `true`, a clear button is displayed when the component has a value."
  377. },
  378. "attribute": "clearable",
  379. "reflect": true,
  380. "defaultValue": "false"
  381. },
  382. "disabled": {
  383. "type": "boolean",
  384. "mutable": false,
  385. "complexType": {
  386. "original": "boolean",
  387. "resolved": "boolean",
  388. "references": {}
  389. },
  390. "required": false,
  391. "optional": false,
  392. "docs": {
  393. "tags": [{
  394. "name": "mdn",
  395. "text": "[disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled)"
  396. }],
  397. "text": "When `true`, interaction is prevented and the component is displayed with lower opacity."
  398. },
  399. "attribute": "disabled",
  400. "reflect": true,
  401. "defaultValue": "false"
  402. },
  403. "hidden": {
  404. "type": "boolean",
  405. "mutable": false,
  406. "complexType": {
  407. "original": "boolean",
  408. "resolved": "boolean",
  409. "references": {}
  410. },
  411. "required": false,
  412. "optional": false,
  413. "docs": {
  414. "tags": [{
  415. "name": "mdn",
  416. "text": "[hidden](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden)"
  417. }],
  418. "text": "When `true`, the component will not be visible."
  419. },
  420. "attribute": "hidden",
  421. "reflect": true,
  422. "defaultValue": "false"
  423. },
  424. "icon": {
  425. "type": "any",
  426. "mutable": false,
  427. "complexType": {
  428. "original": "string | boolean",
  429. "resolved": "boolean | string",
  430. "references": {}
  431. },
  432. "required": false,
  433. "optional": false,
  434. "docs": {
  435. "tags": [],
  436. "text": "When `true`, shows a default recommended icon. Alternatively, pass a Calcite UI Icon name to display a specific icon."
  437. },
  438. "attribute": "icon",
  439. "reflect": true
  440. },
  441. "intlClear": {
  442. "type": "string",
  443. "mutable": false,
  444. "complexType": {
  445. "original": "string",
  446. "resolved": "string",
  447. "references": {}
  448. },
  449. "required": false,
  450. "optional": true,
  451. "docs": {
  452. "tags": [],
  453. "text": "A text label that will appear on the clear button for screen readers."
  454. },
  455. "attribute": "intl-clear",
  456. "reflect": false
  457. },
  458. "intlLoading": {
  459. "type": "string",
  460. "mutable": false,
  461. "complexType": {
  462. "original": "string",
  463. "resolved": "string",
  464. "references": {}
  465. },
  466. "required": false,
  467. "optional": true,
  468. "docs": {
  469. "tags": [{
  470. "name": "default",
  471. "text": "\"Loading\""
  472. }],
  473. "text": "Accessible name that will appear while loading."
  474. },
  475. "attribute": "intl-loading",
  476. "reflect": false,
  477. "defaultValue": "COMMON_TEXT.loading"
  478. },
  479. "iconFlipRtl": {
  480. "type": "boolean",
  481. "mutable": false,
  482. "complexType": {
  483. "original": "boolean",
  484. "resolved": "boolean",
  485. "references": {}
  486. },
  487. "required": false,
  488. "optional": false,
  489. "docs": {
  490. "tags": [],
  491. "text": "When `true`, the icon will be flipped when the element direction is right-to-left (`\"rtl\"`)."
  492. },
  493. "attribute": "icon-flip-rtl",
  494. "reflect": true,
  495. "defaultValue": "false"
  496. },
  497. "label": {
  498. "type": "string",
  499. "mutable": false,
  500. "complexType": {
  501. "original": "string",
  502. "resolved": "string",
  503. "references": {}
  504. },
  505. "required": false,
  506. "optional": true,
  507. "docs": {
  508. "tags": [],
  509. "text": "Accessible name for the component's button or hyperlink."
  510. },
  511. "attribute": "label",
  512. "reflect": false
  513. },
  514. "loading": {
  515. "type": "boolean",
  516. "mutable": false,
  517. "complexType": {
  518. "original": "boolean",
  519. "resolved": "boolean",
  520. "references": {}
  521. },
  522. "required": false,
  523. "optional": false,
  524. "docs": {
  525. "tags": [],
  526. "text": "When `true`, the component is in the loading state and `calcite-progress` is displayed."
  527. },
  528. "attribute": "loading",
  529. "reflect": true,
  530. "defaultValue": "false"
  531. },
  532. "maxLength": {
  533. "type": "number",
  534. "mutable": false,
  535. "complexType": {
  536. "original": "number",
  537. "resolved": "number",
  538. "references": {}
  539. },
  540. "required": false,
  541. "optional": true,
  542. "docs": {
  543. "tags": [{
  544. "name": "mdn",
  545. "text": "[maxlength](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength)"
  546. }],
  547. "text": "Specifies the maximum length of text for the component's value."
  548. },
  549. "attribute": "max-length",
  550. "reflect": true
  551. },
  552. "minLength": {
  553. "type": "number",
  554. "mutable": false,
  555. "complexType": {
  556. "original": "number",
  557. "resolved": "number",
  558. "references": {}
  559. },
  560. "required": false,
  561. "optional": true,
  562. "docs": {
  563. "tags": [{
  564. "name": "mdn",
  565. "text": "[minlength](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength)"
  566. }],
  567. "text": "Specifies the minimum length of text for the component's value."
  568. },
  569. "attribute": "min-length",
  570. "reflect": true
  571. },
  572. "name": {
  573. "type": "string",
  574. "mutable": false,
  575. "complexType": {
  576. "original": "string",
  577. "resolved": "string",
  578. "references": {}
  579. },
  580. "required": false,
  581. "optional": false,
  582. "docs": {
  583. "tags": [{
  584. "name": "mdn",
  585. "text": "[name](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name)"
  586. }],
  587. "text": "Specifies the name of the component."
  588. },
  589. "attribute": "name",
  590. "reflect": true
  591. },
  592. "placeholder": {
  593. "type": "string",
  594. "mutable": false,
  595. "complexType": {
  596. "original": "string",
  597. "resolved": "string",
  598. "references": {}
  599. },
  600. "required": false,
  601. "optional": false,
  602. "docs": {
  603. "tags": [{
  604. "name": "mdn",
  605. "text": "[placeholder](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder)"
  606. }],
  607. "text": "Specifies placeholder text for the component."
  608. },
  609. "attribute": "placeholder",
  610. "reflect": false
  611. },
  612. "prefixText": {
  613. "type": "string",
  614. "mutable": false,
  615. "complexType": {
  616. "original": "string",
  617. "resolved": "string",
  618. "references": {}
  619. },
  620. "required": false,
  621. "optional": true,
  622. "docs": {
  623. "tags": [],
  624. "text": "Adds text to the start of the component."
  625. },
  626. "attribute": "prefix-text",
  627. "reflect": false
  628. },
  629. "readOnly": {
  630. "type": "boolean",
  631. "mutable": false,
  632. "complexType": {
  633. "original": "boolean",
  634. "resolved": "boolean",
  635. "references": {}
  636. },
  637. "required": false,
  638. "optional": false,
  639. "docs": {
  640. "tags": [{
  641. "name": "mdn",
  642. "text": "[readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)"
  643. }],
  644. "text": "When `true`, the component's value can be read, but cannot be modified."
  645. },
  646. "attribute": "read-only",
  647. "reflect": true,
  648. "defaultValue": "false"
  649. },
  650. "required": {
  651. "type": "boolean",
  652. "mutable": false,
  653. "complexType": {
  654. "original": "boolean",
  655. "resolved": "boolean",
  656. "references": {}
  657. },
  658. "required": false,
  659. "optional": false,
  660. "docs": {
  661. "tags": [],
  662. "text": "When `true`, the component must have a value in order for the form to submit."
  663. },
  664. "attribute": "required",
  665. "reflect": true,
  666. "defaultValue": "false"
  667. },
  668. "scale": {
  669. "type": "string",
  670. "mutable": true,
  671. "complexType": {
  672. "original": "Scale",
  673. "resolved": "\"l\" | \"m\" | \"s\"",
  674. "references": {
  675. "Scale": {
  676. "location": "import",
  677. "path": "../interfaces"
  678. }
  679. }
  680. },
  681. "required": false,
  682. "optional": false,
  683. "docs": {
  684. "tags": [],
  685. "text": "Specifies the size of the component."
  686. },
  687. "attribute": "scale",
  688. "reflect": true,
  689. "defaultValue": "\"m\""
  690. },
  691. "status": {
  692. "type": "string",
  693. "mutable": true,
  694. "complexType": {
  695. "original": "Status",
  696. "resolved": "\"idle\" | \"invalid\" | \"valid\"",
  697. "references": {
  698. "Status": {
  699. "location": "import",
  700. "path": "../interfaces"
  701. }
  702. }
  703. },
  704. "required": false,
  705. "optional": false,
  706. "docs": {
  707. "tags": [],
  708. "text": "Specifies the status of the input field, which determines message and icons."
  709. },
  710. "attribute": "status",
  711. "reflect": true,
  712. "defaultValue": "\"idle\""
  713. },
  714. "suffixText": {
  715. "type": "string",
  716. "mutable": false,
  717. "complexType": {
  718. "original": "string",
  719. "resolved": "string",
  720. "references": {}
  721. },
  722. "required": false,
  723. "optional": true,
  724. "docs": {
  725. "tags": [],
  726. "text": "Adds text to the end of the component."
  727. },
  728. "attribute": "suffix-text",
  729. "reflect": false
  730. },
  731. "editingEnabled": {
  732. "type": "boolean",
  733. "mutable": true,
  734. "complexType": {
  735. "original": "boolean",
  736. "resolved": "boolean",
  737. "references": {}
  738. },
  739. "required": false,
  740. "optional": false,
  741. "docs": {
  742. "tags": [{
  743. "name": "internal",
  744. "text": undefined
  745. }],
  746. "text": ""
  747. },
  748. "attribute": "editing-enabled",
  749. "reflect": true,
  750. "defaultValue": "false"
  751. },
  752. "value": {
  753. "type": "string",
  754. "mutable": true,
  755. "complexType": {
  756. "original": "string",
  757. "resolved": "string",
  758. "references": {}
  759. },
  760. "required": false,
  761. "optional": false,
  762. "docs": {
  763. "tags": [],
  764. "text": "The component's value."
  765. },
  766. "attribute": "value",
  767. "reflect": false,
  768. "defaultValue": "\"\""
  769. }
  770. };
  771. }
  772. static get events() {
  773. return [{
  774. "method": "calciteInternalInputTextFocus",
  775. "name": "calciteInternalInputTextFocus",
  776. "bubbles": true,
  777. "cancelable": true,
  778. "composed": true,
  779. "docs": {
  780. "tags": [{
  781. "name": "internal",
  782. "text": undefined
  783. }],
  784. "text": ""
  785. },
  786. "complexType": {
  787. "original": "{\n element: HTMLInputElement;\n value: string;\n }",
  788. "resolved": "{ element: HTMLInputElement; value: string; }",
  789. "references": {
  790. "HTMLInputElement": {
  791. "location": "global"
  792. }
  793. }
  794. }
  795. }, {
  796. "method": "calciteInternalInputTextBlur",
  797. "name": "calciteInternalInputTextBlur",
  798. "bubbles": true,
  799. "cancelable": true,
  800. "composed": true,
  801. "docs": {
  802. "tags": [{
  803. "name": "internal",
  804. "text": undefined
  805. }],
  806. "text": ""
  807. },
  808. "complexType": {
  809. "original": "{ element: HTMLInputElement; value: string }",
  810. "resolved": "{ element: HTMLInputElement; value: string; }",
  811. "references": {
  812. "HTMLInputElement": {
  813. "location": "global"
  814. }
  815. }
  816. }
  817. }, {
  818. "method": "calciteInputTextInput",
  819. "name": "calciteInputTextInput",
  820. "bubbles": true,
  821. "cancelable": true,
  822. "composed": true,
  823. "docs": {
  824. "tags": [],
  825. "text": "Fires each time a new value is typed."
  826. },
  827. "complexType": {
  828. "original": "{\n element: HTMLInputElement;\n nativeEvent: MouseEvent | KeyboardEvent | InputEvent;\n value: string;\n }",
  829. "resolved": "{ element: HTMLInputElement; nativeEvent: KeyboardEvent | MouseEvent | InputEvent; value: string; }",
  830. "references": {
  831. "HTMLInputElement": {
  832. "location": "global"
  833. },
  834. "MouseEvent": {
  835. "location": "global"
  836. },
  837. "KeyboardEvent": {
  838. "location": "global"
  839. },
  840. "InputEvent": {
  841. "location": "global"
  842. }
  843. }
  844. }
  845. }, {
  846. "method": "calciteInputTextChange",
  847. "name": "calciteInputTextChange",
  848. "bubbles": true,
  849. "cancelable": true,
  850. "composed": true,
  851. "docs": {
  852. "tags": [],
  853. "text": "Fires each time a new value is typed and committed."
  854. },
  855. "complexType": {
  856. "original": "void",
  857. "resolved": "void",
  858. "references": {}
  859. }
  860. }];
  861. }
  862. static get methods() {
  863. return {
  864. "setFocus": {
  865. "complexType": {
  866. "signature": "() => Promise<void>",
  867. "parameters": [],
  868. "references": {
  869. "Promise": {
  870. "location": "global"
  871. }
  872. },
  873. "return": "Promise<void>"
  874. },
  875. "docs": {
  876. "text": "Sets focus on the component.",
  877. "tags": []
  878. }
  879. },
  880. "selectText": {
  881. "complexType": {
  882. "signature": "() => Promise<void>",
  883. "parameters": [],
  884. "references": {
  885. "Promise": {
  886. "location": "global"
  887. }
  888. },
  889. "return": "Promise<void>"
  890. },
  891. "docs": {
  892. "text": "Selects all text of the component's `value`.",
  893. "tags": []
  894. }
  895. }
  896. };
  897. }
  898. static get elementRef() { return "el"; }
  899. static get watchers() {
  900. return [{
  901. "propName": "disabled",
  902. "methodName": "disabledWatcher"
  903. }, {
  904. "propName": "value",
  905. "methodName": "valueWatcher"
  906. }, {
  907. "propName": "icon",
  908. "methodName": "updateRequestedIcon"
  909. }];
  910. }
  911. }