diff --git a/packages/calcite-components/src/components.d.ts b/packages/calcite-components/src/components.d.ts index 44ab51c3eaa..01720732f38 100644 --- a/packages/calcite-components/src/components.d.ts +++ b/packages/calcite-components/src/components.d.ts @@ -2034,6 +2034,10 @@ export namespace Components { * @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) */ "autocomplete": string; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + */ + "autofocus": boolean; /** * 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. */ @@ -2044,6 +2048,11 @@ export namespace Components { */ "disabled": boolean; "editingEnabled": boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "enterKeyHint": string; /** * When `type` is `"file"`, specifies the component's selected files. * @mdn https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files @@ -2065,6 +2074,11 @@ export namespace Components { * When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ "iconFlipRtl": boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "inputMode": string; /** * Accessible name for the component. */ @@ -2364,6 +2378,10 @@ export namespace Components { * @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) */ "autocomplete": string; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + */ + "autofocus": boolean; /** * When `true`, a clear button is displayed when the component has a value. */ @@ -2374,6 +2392,11 @@ export namespace Components { */ "disabled": boolean; "editingEnabled": boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "enterKeyHint": string; /** * The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any. */ @@ -2391,6 +2414,11 @@ export namespace Components { * When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ "iconFlipRtl": boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "inputMode": string; /** * When `true`, restricts the component to integer numbers only and disables exponential notation. */ @@ -2522,6 +2550,10 @@ export namespace Components { * @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) */ "autocomplete": string; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + */ + "autofocus": boolean; /** * When `true`, a clear button is displayed when the component has a value. */ @@ -2532,6 +2564,11 @@ export namespace Components { */ "disabled": boolean; "editingEnabled": boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "enterKeyHint": string; /** * The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any. */ @@ -2545,6 +2582,11 @@ export namespace Components { * When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ "iconFlipRtl": boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "inputMode": string; /** * Accessible name for the component's button or hyperlink. */ @@ -9748,6 +9790,10 @@ declare namespace LocalJSX { * @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) */ "autocomplete"?: string; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + */ + "autofocus"?: boolean; /** * 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. */ @@ -9758,6 +9804,11 @@ declare namespace LocalJSX { */ "disabled"?: boolean; "editingEnabled"?: boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "enterKeyHint"?: string; /** * When `type` is `"file"`, specifies the component's selected files. * @mdn https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files @@ -9779,6 +9830,11 @@ declare namespace LocalJSX { * When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ "iconFlipRtl"?: boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "inputMode"?: string; /** * Accessible name for the component. */ @@ -10091,6 +10147,10 @@ declare namespace LocalJSX { * @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) */ "autocomplete"?: string; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + */ + "autofocus"?: boolean; /** * When `true`, a clear button is displayed when the component has a value. */ @@ -10101,6 +10161,11 @@ declare namespace LocalJSX { */ "disabled"?: boolean; "editingEnabled"?: boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "enterKeyHint"?: string; /** * The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any. */ @@ -10118,6 +10183,11 @@ declare namespace LocalJSX { * When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ "iconFlipRtl"?: boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "inputMode"?: string; /** * When `true`, restricts the component to integer numbers only and disables exponential notation. */ @@ -10251,6 +10321,10 @@ declare namespace LocalJSX { * @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) */ "autocomplete"?: string; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + */ + "autofocus"?: boolean; /** * When `true`, a clear button is displayed when the component has a value. */ @@ -10261,6 +10335,11 @@ declare namespace LocalJSX { */ "disabled"?: boolean; "editingEnabled"?: boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "enterKeyHint"?: string; /** * The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any. */ @@ -10274,6 +10353,11 @@ declare namespace LocalJSX { * When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ "iconFlipRtl"?: boolean; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * @futureBreaking kebab-cased attribute will not be supported in a future release + */ + "inputMode"?: string; /** * Accessible name for the component's button or hyperlink. */ diff --git a/packages/calcite-components/src/components/input-number/input-number.e2e.ts b/packages/calcite-components/src/components/input-number/input-number.e2e.ts index 7656be8e1e1..7891155583d 100644 --- a/packages/calcite-components/src/components/input-number/input-number.e2e.ts +++ b/packages/calcite-components/src/components/input-number/input-number.e2e.ts @@ -15,7 +15,11 @@ import { import { getElementRect, getElementXY, selectText } from "../../tests/utils"; import { letterKeys, numberKeys } from "../../utils/key"; import { locales, numberStringFormatter } from "../../utils/locale"; -import { testHiddenInputSyncing, testPostValidationFocusing } from "../input/common/tests"; +import { + testWorkaroundForGlobalPropRemoval, + testHiddenInputSyncing, + testPostValidationFocusing, +} from "../input/common/tests"; describe("calcite-input-number", () => { const delayFor2UpdatesInMs = 200; @@ -1757,6 +1761,8 @@ describe("calcite-input-number", () => { testHiddenInputSyncing("calcite-input-number"); }); + testWorkaroundForGlobalPropRemoval("calcite-input-number"); + describe("translation support", () => { t9n("calcite-input-number"); }); diff --git a/packages/calcite-components/src/components/input-number/input-number.tsx b/packages/calcite-components/src/components/input-number/input-number.tsx index 122a97273fe..3b27c5b7901 100644 --- a/packages/calcite-components/src/components/input-number/input-number.tsx +++ b/packages/calcite-components/src/components/input-number/input-number.tsx @@ -119,6 +119,14 @@ export class InputNumber /** Specifies the text alignment of the component's value. */ @Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start"; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() autofocus: boolean; + /** * When `true`, a clear button is displayed when the component has a value. */ @@ -136,6 +144,15 @@ export class InputNumber this.setDisabledAction(); } + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * + * @futureBreaking kebab-cased attribute will not be supported in a future release + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() enterKeyHint: string; + /** * The `id` of the form that will be associated with the component. * @@ -158,6 +175,15 @@ export class InputNumber /** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ @Prop({ reflect: true }) iconFlipRtl = false; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * + * @futureBreaking kebab-cased attribute will not be supported in a future release + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() inputMode: string; + /** When `true`, restricts the component to integer numbers only and disables exponential notation. */ @Prop() integer = false; @@ -1059,8 +1085,8 @@ export class InputNumber autofocus={this.el.autofocus ? true : null} defaultValue={this.defaultValue} disabled={this.disabled ? true : null} - enterKeyHint={this.el.enterKeyHint} - inputMode={this.el.inputMode} + enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")} + inputMode={this.el.inputMode || this.el.getAttribute("inputmode")} key="localized-input" maxLength={this.maxLength} minLength={this.minLength} diff --git a/packages/calcite-components/src/components/input-text/input-text.e2e.ts b/packages/calcite-components/src/components/input-text/input-text.e2e.ts index 876b7b01ed7..03639aad53c 100644 --- a/packages/calcite-components/src/components/input-text/input-text.e2e.ts +++ b/packages/calcite-components/src/components/input-text/input-text.e2e.ts @@ -12,7 +12,11 @@ import { t9n, } from "../../tests/commonTests"; import { selectText } from "../../tests/utils"; -import { testHiddenInputSyncing, testPostValidationFocusing } from "../input/common/tests"; +import { + testHiddenInputSyncing, + testPostValidationFocusing, + testWorkaroundForGlobalPropRemoval, +} from "../input/common/tests"; describe("calcite-input-text", () => { describe("labelable", () => { @@ -469,6 +473,8 @@ describe("calcite-input-text", () => { testHiddenInputSyncing("calcite-input-text"); }); + testWorkaroundForGlobalPropRemoval("calcite-input-text"); + describe("translation support", () => { t9n("calcite-input-text"); }); diff --git a/packages/calcite-components/src/components/input-text/input-text.tsx b/packages/calcite-components/src/components/input-text/input-text.tsx index 8a0362a4607..bf2aa80fa9e 100644 --- a/packages/calcite-components/src/components/input-text/input-text.tsx +++ b/packages/calcite-components/src/components/input-text/input-text.tsx @@ -95,6 +95,14 @@ export class InputText /** Specifies the text alignment of the component's value. */ @Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start"; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() autofocus: boolean; + /** * When `true`, a clear button is displayed when the component has a value. */ @@ -112,6 +120,15 @@ export class InputText this.setDisabledAction(); } + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * + * @futureBreaking kebab-cased attribute will not be supported in a future release + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() enterKeyHint: string; + /** * The `id` of the form that will be associated with the component. * @@ -130,6 +147,15 @@ export class InputText /** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ @Prop({ reflect: true }) iconFlipRtl = false; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * + * @futureBreaking kebab-cased attribute will not be supported in a future release + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() inputMode: string; + /** Accessible name for the component's button or hyperlink. */ @Prop() label: string; @@ -632,7 +658,6 @@ export class InputText /> ); const prefixText =
{this.prefixText}
; - const suffixText =
{this.suffixText}
; const childEl = ( @@ -646,8 +671,8 @@ export class InputText }} defaultValue={this.defaultValue} disabled={this.disabled ? true : null} - enterKeyHint={this.el.enterKeyHint} - inputMode={this.el.inputMode} + enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")} + inputMode={this.el.inputMode || this.el.getAttribute("inputmode")} maxLength={this.maxLength} minLength={this.minLength} name={this.name} diff --git a/packages/calcite-components/src/components/input/common/tests.ts b/packages/calcite-components/src/components/input/common/tests.ts index 94360f0535a..800851b3e32 100644 --- a/packages/calcite-components/src/components/input/common/tests.ts +++ b/packages/calcite-components/src/components/input/common/tests.ts @@ -59,9 +59,9 @@ export function testHiddenInputSyncing( const page = await newE2EPage(); await page.setContent(html`
- <${inputTag} name="form-name"> + <${inputTag} name="form-name">
- `); + `); const input = await page.find(inputTag); const hiddenInput = await page.find(`input[slot=${hiddenFormInputSlotName}]`); @@ -115,3 +115,53 @@ export function testHiddenInputSyncing( await assertNumericProps(); }); } + +export function testWorkaroundForGlobalPropRemoval( + inputTag: Extract, +): void { + const testInputMode = "tel"; + const testEnterKeyHint = "done"; + + it("supports global attribute kebab-casing (deprecated)", async () => { + const page = await newE2EPage(); + await page.setContent(html` + <${inputTag} autofocus input-mode="${testInputMode}" enter-key-hint="${testEnterKeyHint}"> + `); + + const input = await page.find(`${inputTag} >>> input`); + + expect(input.getAttribute("autofocus")).toBe(""); + expect(input.getAttribute("inputmode")).toBe(testInputMode); + expect(input.getAttribute("enterkeyhint")).toBe(testEnterKeyHint); + }); + + it("supports global attribute casing", async () => { + const page = await newE2EPage(); + await page.setContent(html` + <${inputTag} autofocus inputmode="${testInputMode}" enterkeyhint="${testEnterKeyHint}"> + `); + + const input = await page.find(`${inputTag} >>> input`); + + expect(input.getAttribute("autofocus")).toBe(""); + expect(input.getAttribute("inputmode")).toBe(testInputMode); + expect(input.getAttribute("enterkeyhint")).toBe(testEnterKeyHint); + }); + + it("supports global props", async () => { + const page = await newE2EPage(); + await page.setContent(html`<${inputTag}>`); + + const input = await page.find(inputTag); + const internalInput = await page.find(`${inputTag} >>> input`); + + input.setProperty("autofocus", true); + input.setProperty("inputMode", testInputMode); + input.setProperty("enterKeyHint", testEnterKeyHint); + await page.waitForChanges(); + + expect(internalInput.getAttribute("autofocus")).toBe(""); + expect(internalInput.getAttribute("inputmode")).toBe(testInputMode); + expect(internalInput.getAttribute("enterkeyhint")).toBe(testEnterKeyHint); + }); +} diff --git a/packages/calcite-components/src/components/input/input.e2e.ts b/packages/calcite-components/src/components/input/input.e2e.ts index 38c8a036d1e..9ace0e4ba84 100644 --- a/packages/calcite-components/src/components/input/input.e2e.ts +++ b/packages/calcite-components/src/components/input/input.e2e.ts @@ -15,7 +15,7 @@ import { html } from "../../../support/formatting"; import { letterKeys, numberKeys } from "../../utils/key"; import { locales, numberStringFormatter } from "../../utils/locale"; import { getElementRect, getElementXY, selectText } from "../../tests/utils"; -import { testHiddenInputSyncing, testPostValidationFocusing } from "./common/tests"; +import { testHiddenInputSyncing, testPostValidationFocusing, testWorkaroundForGlobalPropRemoval } from "./common/tests"; describe("calcite-input", () => { const delayFor2UpdatesInMs = 200; @@ -2062,6 +2062,8 @@ describe("calcite-input", () => { testHiddenInputSyncing("calcite-input"); }); + testWorkaroundForGlobalPropRemoval("calcite-input"); + describe("translation support", () => { t9n("calcite-input"); }); diff --git a/packages/calcite-components/src/components/input/input.tsx b/packages/calcite-components/src/components/input/input.tsx index 929e15fb9b5..2be5d1d9a87 100644 --- a/packages/calcite-components/src/components/input/input.tsx +++ b/packages/calcite-components/src/components/input/input.tsx @@ -115,6 +115,14 @@ export class Input /** Specifies the text alignment of the component's value. */ @Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start"; + /** + * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() autofocus: boolean; + /** * 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. */ @@ -132,6 +140,15 @@ export class Input this.setDisabledAction(); } + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * + * @futureBreaking kebab-cased attribute will not be supported in a future release + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() enterKeyHint: string; + /** * The `id` of the form that will be associated with the component. * @@ -152,6 +169,15 @@ export class Input /** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */ @Prop({ reflect: true }) iconFlipRtl = false; + /** + * Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123 + * + * @futureBreaking kebab-cased attribute will not be supported in a future release + * @internal + */ + // eslint-disable-next-line @stencil-community/reserved-member-names + @Prop() inputMode: string; + /** Accessible name for the component. */ @Prop() label: string; @@ -1135,20 +1161,23 @@ export class Input ); const prefixText =
{this.prefixText}
; - const suffixText =
{this.suffixText}
; + const autofocus = this.el.autofocus || this.el.hasAttribute("autofocus") ? true : null; + const enterKeyHint = this.el.enterKeyHint || this.el.getAttribute("enterkeyhint"); + const inputMode = this.el.inputMode || this.el.getAttribute("inputmode"); + const localeNumberInput = this.type === "number" ? (