diff --git a/cast/src/launcher/layout/hc-connect.ts b/cast/src/launcher/layout/hc-connect.ts index 8aab0f0e6f..a8a89f9c6d 100644 --- a/cast/src/launcher/layout/hc-connect.ts +++ b/cast/src/launcher/layout/hc-connect.ts @@ -26,7 +26,7 @@ import "../../../../src/components/ha-svg-icon"; import "../../../../src/layouts/hass-loading-screen"; import { registerServiceWorker } from "../../../../src/util/register-service-worker"; import "./hc-layout"; -import "../../../../src/components/ha-textfield"; +import "../../../../src/components/input/ha-input"; import "../../../../src/components/ha-button"; const seeFAQ = (qid) => html` @@ -123,11 +123,11 @@ export class HcConnect extends LitElement { To get started, enter your Home Assistant URL and click authorize. If you want a preview instead, click the show demo button.

- + > ${this.error ? html`

${this.error}

` : ""}
@@ -204,7 +204,7 @@ export class HcConnect extends LitElement { } private async _handleConnect() { - const inputEl = this.shadowRoot!.querySelector("ha-textfield")!; + const inputEl = this.shadowRoot!.querySelector("ha-input")!; const value = inputEl.value || ""; this.error = undefined; @@ -319,7 +319,7 @@ export class HcConnect extends LitElement { flex: 1; } - ha-textfield { + ha-input { width: 100%; } `; diff --git a/src/components/ha-textfield.ts b/src/components/ha-textfield.ts deleted file mode 100644 index 000c0055ee..0000000000 --- a/src/components/ha-textfield.ts +++ /dev/null @@ -1,294 +0,0 @@ -import type { PropertyValues, TemplateResult } from "lit"; -import { css, html, LitElement, nothing } from "lit"; -import { customElement, property, query } from "lit/decorators"; -import "./input/ha-input"; -import type { HaInput } from "./input/ha-input"; - -/** - * Legacy wrapper around ha-input that preserves the mwc-textfield API. - * New code should use ha-input directly. - * @deprecated Use ha-input instead. - */ -@customElement("ha-textfield") -export class HaTextField extends LitElement { - @property({ type: String }) - public value = ""; - - @property({ type: String }) - public type: - | "text" - | "search" - | "tel" - | "url" - | "email" - | "password" - | "date" - | "month" - | "week" - | "time" - | "datetime-local" - | "number" - | "color" = "text"; - - @property({ type: String }) - public label = ""; - - @property({ type: String }) - public placeholder = ""; - - @property({ type: String }) - public prefix = ""; - - @property({ type: String }) - public suffix = ""; - - @property({ type: Boolean }) - // @ts-ignore - public icon = false; - - @property({ type: Boolean }) - // @ts-ignore - // eslint-disable-next-line lit/attribute-names - public iconTrailing = false; - - @property({ type: Boolean }) - public disabled = false; - - @property({ type: Boolean }) - public required = false; - - @property({ type: Number, attribute: "minlength" }) - public minLength = -1; - - @property({ type: Number, attribute: "maxlength" }) - public maxLength = -1; - - @property({ type: Boolean, reflect: true }) - public outlined = false; - - @property({ type: String }) - public helper = ""; - - @property({ type: Boolean, attribute: "validateoninitialrender" }) - public validateOnInitialRender = false; - - @property({ type: String, attribute: "validationmessage" }) - public validationMessage = ""; - - @property({ type: Boolean, attribute: "autovalidate" }) - public autoValidate = false; - - @property({ type: String }) - public pattern = ""; - - @property() - public min: number | string = ""; - - @property() - public max: number | string = ""; - - @property() - public step: number | "any" | null = null; - - @property({ type: Number }) - public size: number | null = null; - - @property({ type: Boolean, attribute: "helperpersistent" }) - public helperPersistent = false; - - @property({ attribute: "charcounter" }) - public charCounter: boolean | "external" | "internal" = false; - - @property({ type: Boolean, attribute: "endaligned" }) - public endAligned = false; - - @property({ type: String, attribute: "inputmode" }) - public inputMode = ""; - - @property({ type: Boolean, reflect: true, attribute: "readonly" }) - public readOnly = false; - - @property({ type: String }) - public name = ""; - - @property({ type: String }) - // eslint-disable-next-line lit/no-native-attributes - public autocapitalize = ""; - - // --- ha-textfield-specific properties --- - - @property({ type: Boolean }) - public invalid = false; - - @property({ attribute: "error-message" }) - public errorMessage?: string; - - @property() - public autocomplete?: string; - - @property({ type: Boolean }) - public autocorrect = true; - - @property({ attribute: "input-spellcheck" }) - public inputSpellcheck?: string; - - @query("ha-input") - private _haInput?: HaInput; - - static shadowRootOptions: ShadowRootInit = { - mode: "open", - delegatesFocus: true, - }; - - public get formElement(): HTMLInputElement | undefined { - return (this._haInput as any)?._input?.input; - } - - public select(): void { - this._haInput?.select(); - } - - public setSelectionRange( - selectionStart: number, - selectionEnd: number, - selectionDirection?: "forward" | "backward" | "none" - ): void { - this._haInput?.setSelectionRange( - selectionStart, - selectionEnd, - selectionDirection - ); - } - - public setRangeText( - replacement: string, - start?: number, - end?: number, - selectMode?: "select" | "start" | "end" | "preserve" - ): void { - this._haInput?.setRangeText(replacement, start, end, selectMode); - } - - public checkValidity(): boolean { - return this._haInput?.checkValidity() ?? true; - } - - public reportValidity(): boolean { - return this._haInput?.reportValidity() ?? true; - } - - public setCustomValidity(message: string): void { - this.validationMessage = message; - this.invalid = !!message; - } - - /** No-op. Preserved for backward compatibility. */ - public layout(): void { - // no-op — mwc-textfield needed this for notched outline recalculation - } - - protected override firstUpdated(changedProperties: PropertyValues): void { - super.firstUpdated(changedProperties); - if (this.validateOnInitialRender) { - this.reportValidity(); - } - } - - protected override updated(changedProperties: PropertyValues): void { - super.updated(changedProperties); - - if (changedProperties.has("invalid") && this._haInput) { - if ( - this.invalid || - (changedProperties.get("invalid") !== undefined && !this.invalid) - ) { - this.reportValidity(); - } - } - } - - protected override render(): TemplateResult { - const errorMsg = this.errorMessage || this.validationMessage; - return html` - 0 ? this.minLength : undefined} - .maxlength=${this.maxLength > 0 ? this.maxLength : undefined} - .min=${this.min !== "" ? this.min : undefined} - .max=${this.max !== "" ? this.max : undefined} - .step=${this.step ?? undefined} - .name=${this.name || undefined} - .autocomplete=${this.autocomplete} - .autocorrect=${this.autocorrect} - .spellcheck=${this.inputSpellcheck === "true"} - .inputmode=${this.inputMode} - .autocapitalize=${this.autocapitalize || ""} - .invalid=${this.invalid} - .validationMessage=${errorMsg || ""} - .autoValidate=${this.autoValidate} - .hint=${this.helper} - .withoutSpinButtons=${this.type === "number"} - .insetLabel=${this.prefix} - @input=${this._onInput} - @change=${this._onChange} - > - ${this.icon - ? html`` - : nothing} - ${this.prefix - ? html`${this.prefix}` - : nothing} - ${this.suffix - ? html`${this.suffix}` - : nothing} - ${this.iconTrailing - ? html`` - : nothing} - - `; - } - - private _onInput(): void { - this.value = this._haInput?.value ?? ""; - } - - private _onChange(): void { - this.value = this._haInput?.value ?? ""; - } - - static override styles = css` - :host { - display: inline-flex; - flex-direction: column; - outline: none; - } - - ha-input { - --ha-input-padding-bottom: 0; - width: 100%; - } - - .prefix, - .suffix { - color: var(--secondary-text-color); - } - - .prefix { - padding-top: var(--ha-space-3); - margin-inline-end: var(--text-field-prefix-padding-right); - } - `; -} - -declare global { - interface HTMLElementTagNameMap { - "ha-textfield": HaTextField; - } -} diff --git a/src/components/input/ha-input.ts b/src/components/input/ha-input.ts index bb82d3657e..b003624b31 100644 --- a/src/components/input/ha-input.ts +++ b/src/components/input/ha-input.ts @@ -235,7 +235,8 @@ export class HaInput extends LitElement { this, "label", "hint", - "input" + "input", + "start" ); static shadowRootOptions: ShadowRootInit = { @@ -318,6 +319,8 @@ export class HaInput extends LitElement { ? false : this._hasSlotController.test("hint"); + const hasStartSlot = this._hasSlotController.test("start"); + return html` `; } diff --git a/src/panels/config/automation/action/types/ha-automation-action-parallel.ts b/src/panels/config/automation/action/types/ha-automation-action-parallel.ts index 88a1fa15a1..02f7c9ff75 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-parallel.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-parallel.ts @@ -2,7 +2,6 @@ import type { CSSResultGroup } from "lit"; import { html, LitElement } from "lit"; import { customElement, property, query } from "lit/decorators"; import { fireEvent } from "../../../../../common/dom/fire_event"; -import "../../../../../components/ha-textfield"; import type { Action, ParallelAction } from "../../../../../data/script"; import { haStyle } from "../../../../../resources/styles"; import type { HomeAssistant } from "../../../../../types"; diff --git a/src/panels/config/automation/action/types/ha-automation-action-sequence.ts b/src/panels/config/automation/action/types/ha-automation-action-sequence.ts index 9a8b93522d..a4d21e7922 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-sequence.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-sequence.ts @@ -1,14 +1,13 @@ import type { CSSResultGroup } from "lit"; import { html, LitElement } from "lit"; -import { query, customElement, property } from "lit/decorators"; +import { customElement, property, query } from "lit/decorators"; import { fireEvent } from "../../../../../common/dom/fire_event"; -import "../../../../../components/ha-textfield"; import type { Action, SequenceAction } from "../../../../../data/script"; import { haStyle } from "../../../../../resources/styles"; import type { HomeAssistant } from "../../../../../types"; import "../ha-automation-action"; -import type { ActionElement } from "../ha-automation-action-row"; import type HaAutomationAction from "../ha-automation-action"; +import type { ActionElement } from "../ha-automation-action-row"; @customElement("ha-automation-action-sequence") export class HaSequenceAction extends LitElement implements ActionElement { diff --git a/src/panels/config/blueprint/dialog-import-blueprint.ts b/src/panels/config/blueprint/dialog-import-blueprint.ts index 3fae5f9a8d..d6f0590bcd 100644 --- a/src/panels/config/blueprint/dialog-import-blueprint.ts +++ b/src/panels/config/blueprint/dialog-import-blueprint.ts @@ -2,23 +2,23 @@ import { mdiClose, mdiOpenInNew } from "@mdi/js"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, query, state } from "lit/decorators"; import { fireEvent } from "../../../common/dom/fire_event"; -import { documentationUrl } from "../../../util/documentation-url"; +import { withViewTransition } from "../../../common/util/view-transition"; import "../../../components/ha-alert"; import "../../../components/ha-button"; import "../../../components/ha-code-editor"; -import "../../../components/ha-dialog-header"; +import "../../../components/ha-dialog"; import "../../../components/ha-dialog-footer"; +import "../../../components/ha-dialog-header"; import "../../../components/ha-expansion-panel"; import "../../../components/ha-markdown"; import "../../../components/ha-spinner"; -import "../../../components/ha-textfield"; -import "../../../components/ha-dialog"; -import type { HaTextField } from "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import type { BlueprintImportResult } from "../../../data/blueprint"; import { importBlueprint, saveBlueprint } from "../../../data/blueprint"; import { haStyleDialog } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; -import { withViewTransition } from "../../../common/util/view-transition"; +import { documentationUrl } from "../../../util/documentation-url"; @customElement("ha-dialog-import-blueprint") class DialogImportBlueprint extends LitElement { @@ -42,7 +42,7 @@ class DialogImportBlueprint extends LitElement { @state() private _sourceUrlWarning = false; - @query("#input") private _input?: HaTextField; + @query("#input") private _input?: HaInput; public showDialog(params): void { this._params = params; @@ -131,14 +131,14 @@ class DialogImportBlueprint extends LitElement { ` : html` - + > `} - + > `}
@@ -328,8 +328,7 @@ class DialogImportBlueprint extends LitElement { margin-top: 0; margin-bottom: var(--ha-space-2); } - ha-textfield { - display: block; + ha-input { margin-top: var(--ha-space-6); } ha-alert { diff --git a/src/panels/config/category/dialog-assign-category.ts b/src/panels/config/category/dialog-assign-category.ts index bee7b2130d..c4bbfab7a3 100644 --- a/src/panels/config/category/dialog-assign-category.ts +++ b/src/panels/config/category/dialog-assign-category.ts @@ -53,7 +53,6 @@ class DialogAssignCategory extends LitElement { const entry = this._params.entityReg.categories[this._params.scope]; return html` ${this._error}` : ""}
- + > ) { this._error = undefined; this._icon = ev.detail.value; } @@ -144,10 +146,8 @@ class DialogCategoryDetail extends DialogMixin${this._error}` : nothing} - + >
- + >
- - + ${this.hass.localize( + "ui.panel.config.core.section.core.core_config.elevation_meters" + )} +
${this.hass.localize( @@ -358,8 +362,8 @@ class HaConfigSectionGeneral extends LitElement { this[`_${target.getAttribute("name")}`] = ev.detail.value; } - private _handleChange(ev: Event) { - const target = ev.currentTarget as HaTextField; + private _handleChange(ev: InputEvent) { + const target = ev.currentTarget as HaInput; this[`_${target.name}`] = target.value; } diff --git a/src/panels/config/developer-tools/event/developer-tools-event.ts b/src/panels/config/developer-tools/event/developer-tools-event.ts index 72ce29730b..3cb0e03ed1 100644 --- a/src/panels/config/developer-tools/event/developer-tools-event.ts +++ b/src/panels/config/developer-tools/event/developer-tools-event.ts @@ -1,17 +1,18 @@ import type { CSSResultGroup, TemplateResult } from "lit"; import { LitElement, css, html } from "lit"; import { customElement, property, state } from "lit/decorators"; -import "../../../../components/ha-yaml-editor"; -import "../../../../components/ha-textfield"; +import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; import "../../../../components/ha-card"; +import "../../../../components/ha-yaml-editor"; +import "../../../../components/input/ha-input"; +import type { HaInput } from "../../../../components/input/ha-input"; import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box"; +import { haStyle } from "../../../../resources/styles"; +import type { HomeAssistant } from "../../../../types"; import { documentationUrl } from "../../../../util/documentation-url"; import "./event-subscribe-card"; import "./events-list"; -import { haStyle } from "../../../../resources/styles"; -import type { HomeAssistant } from "../../../../types"; -import { fireEvent } from "../../../../common/dom/fire_event"; @customElement("developer-tools-event") class HaPanelDevEvent extends LitElement { @@ -55,7 +56,7 @@ class HaPanelDevEvent extends LitElement {

- + >

${this.hass.localize( "ui.panel.config.developer-tools.tabs.events.data" @@ -117,8 +118,8 @@ class HaPanelDevEvent extends LitElement { this._selectedEventType = ev.detail.eventType; } - private _eventTypeChanged(ev) { - this._eventType = ev.target.value; + private _eventTypeChanged(ev: InputEvent) { + this._eventType = (ev.target as HaInput).value ?? ""; } private _yamlChanged(ev) { @@ -178,10 +179,6 @@ class HaPanelDevEvent extends LitElement { margin-top: var(--ha-space-2); } - ha-textfield { - display: block; - } - event-subscribe-card { display: block; margin-top: var(--ha-space-4); diff --git a/src/panels/config/developer-tools/event/event-subscribe-card.ts b/src/panels/config/developer-tools/event/event-subscribe-card.ts index 986c8fb305..6e1642b8bc 100644 --- a/src/panels/config/developer-tools/event/event-subscribe-card.ts +++ b/src/panels/config/developer-tools/event/event-subscribe-card.ts @@ -4,11 +4,12 @@ import { css, html, LitElement } from "lit"; import { customElement, property, state } from "lit/decorators"; import { repeat } from "lit/directives/repeat"; import { formatTime } from "../../../../common/datetime/format_time"; -import "../../../../components/ha-card"; -import "../../../../components/ha-textfield"; -import "../../../../components/ha-yaml-editor"; -import "../../../../components/ha-button"; import "../../../../components/ha-alert"; +import "../../../../components/ha-button"; +import "../../../../components/ha-card"; +import "../../../../components/ha-yaml-editor"; +import "../../../../components/input/ha-input"; +import type { HaInput } from "../../../../components/input/ha-input"; import type { HomeAssistant } from "../../../../types"; @customElement("event-subscribe-card") @@ -62,7 +63,7 @@ class EventSubscribeCard extends LitElement { )} >

- - + + > ${this._error ? html`${this._error}` : ""} @@ -144,13 +144,13 @@ class EventSubscribeCard extends LitElement { `; } - private _valueChanged(ev): void { - this._eventType = ev.target.value; + private _valueChanged(ev: InputEvent): void { + this._eventType = (ev.target as HaInput).value ?? ""; this._error = undefined; } - private _filterChanged(ev): void { - this._eventFilter = ev.target.value; + private _filterChanged(ev: InputEvent): void { + this._eventFilter = (ev.target as HaInput).value ?? ""; } private _testEventFilter(event: HassEvent): boolean { @@ -231,9 +231,8 @@ class EventSubscribeCard extends LitElement { } static styles = css` - ha-textfield { - display: block; - margin-bottom: var(--ha-space-4); + ha-input { + margin-bottom: var(--ha-space-2); } .error-message { margin-top: var(--ha-space-2); diff --git a/src/panels/config/developer-tools/state/developer-tools-state.ts b/src/panels/config/developer-tools/state/developer-tools-state.ts index df3c974135..5bde5c7012 100644 --- a/src/panels/config/developer-tools/state/developer-tools-state.ts +++ b/src/panels/config/developer-tools/state/developer-tools-state.ts @@ -24,6 +24,8 @@ import "../../../../components/ha-svg-icon"; import "../../../../components/ha-tip"; import "../../../../components/ha-yaml-editor"; import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; +import "../../../../components/input/ha-input"; +import type { HaInput } from "../../../../components/input/ha-input"; import "../../../../components/input/ha-input-search"; import type { HaInputSearch } from "../../../../components/input/ha-input-search"; import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box"; @@ -161,7 +163,7 @@ class HaPanelDevState extends LitElement {
` : nothing} - + >

${this.hass.localize( "ui.panel.config.developer-tools.tabs.states.state_attributes" @@ -313,8 +315,8 @@ class HaPanelDevState extends LitElement { this._expanded = true; } - private _stateChanged(ev) { - this._state = ev.target.value; + private _stateChanged(ev: InputEvent) { + this._state = (ev.target as HaInput).value ?? ""; } private _entityFilterChanged(ev: InputEvent) { @@ -513,10 +515,6 @@ class HaPanelDevState extends LitElement { --ha-input-padding-bottom: 0; } - ha-textfield { - display: block; - } - .heading { display: flex; justify-content: space-between; diff --git a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts index dc21ac990b..3d07bf475e 100644 --- a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts +++ b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts @@ -3,14 +3,15 @@ import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import { computeDeviceNameDisplay } from "../../../../common/entity/compute_device_name"; +import "../../../../components/ha-adaptive-dialog"; import "../../../../components/ha-alert"; import "../../../../components/ha-area-picker"; -import "../../../../components/ha-adaptive-dialog"; -import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-button"; +import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-labels-picker"; import type { HaSwitch } from "../../../../components/ha-switch"; -import "../../../../components/ha-textfield"; +import "../../../../components/input/ha-input"; +import type { HaInput } from "../../../../components/input/ha-input"; import type { DeviceRegistryEntry } from "../../../../data/device/device_registry"; import { haStyle, haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; @@ -77,7 +78,7 @@ class DialogDeviceRegistryDetail extends LitElement { ? html`${this._error} ` : ""}

- + > - - + - - + ${this._costs === "number" - ? html` - ` + ${unitPrice + ? html`${unitPrice}` + : nothing} + ` : ""} @@ -339,10 +343,10 @@ export class DialogEnergyGasSettings this._costs = input.value as any; } - private _numberPriceChanged(ev) { + private _numberPriceChanged(ev: InputEvent) { this._source = { ...this._source!, - number_energy_price: Number(ev.target.value), + number_energy_price: Number((ev.target as HTMLInputElement).value), entity_energy_price: null, stat_cost: null, }; diff --git a/src/panels/config/energy/dialogs/dialog-energy-grid-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-grid-settings.ts index c11aaaa6de..7b0d387663 100644 --- a/src/panels/config/energy/dialogs/dialog-energy-grid-settings.ts +++ b/src/panels/config/energy/dialogs/dialog-energy-grid-settings.ts @@ -5,12 +5,12 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/entity/ha-entity-picker"; import "../../../../components/entity/ha-statistic-picker"; import "../../../../components/ha-button"; +import "../../../../components/ha-dialog"; import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-formfield"; import "../../../../components/ha-radio"; -import "../../../../components/ha-textfield"; -import "../../../../components/ha-dialog"; import type { HaRadio } from "../../../../components/ha-radio"; +import "../../../../components/input/ha-input"; import type { GridSourceTypeEnergyPreference, PowerConfig, @@ -312,16 +312,19 @@ export class DialogEnergyGridSettings : nothing} ${this._importCostType === "number" ? html` - + > + ${this.hass.config.currency}/kWh + ` : nothing} ${hasExport @@ -415,16 +418,19 @@ export class DialogEnergyGridSettings : nothing} ${this._exportCostType === "number" ? html` - + > + ${this.hass.config.currency}/kWh + ` : nothing} ` @@ -628,14 +634,17 @@ export class DialogEnergyGridSettings haStyleDialog, css` ha-statistic-picker, - ha-entity-picker, - ha-textfield { + ha-entity-picker { display: block; margin-bottom: var(--ha-space-4); } + ha-input { + margin-bottom: var(--ha-space-4); + --ha-input-padding-bottom: 0; + } ha-statistic-picker:last-of-type, ha-entity-picker:last-of-type, - ha-textfield:last-of-type { + ha-input:last-of-type { margin-bottom: 0; } ha-formfield { diff --git a/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts index 499f4046e8..69aadc6276 100644 --- a/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts +++ b/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts @@ -11,7 +11,7 @@ import "../../../../components/ha-radio"; import "../../../../components/ha-markdown"; import "../../../../components/ha-dialog"; import type { HaRadio } from "../../../../components/ha-radio"; -import "../../../../components/ha-textfield"; +import "../../../../components/input/ha-input"; import type { WaterSourceTypeEnergyPreference } from "../../../../data/energy"; import { emptyWaterEnergyPreference, @@ -240,18 +240,20 @@ export class DialogEnergyWaterSettings > ${this._costs === "number" - ? html` - ` + ${unitPriceFixed} + ` : ""} @@ -279,10 +281,10 @@ export class DialogEnergyWaterSettings this._costs = input.value as any; } - private _numberPriceChanged(ev) { + private _numberPriceChanged(ev: InputEvent) { this._source = { ...this._source!, - number_energy_price: Number(ev.target.value), + number_energy_price: Number((ev.target as HTMLInputElement).value), entity_energy_price: null, stat_cost: null, }; diff --git a/src/panels/config/entities/entity-registry-settings-editor.ts b/src/panels/config/entities/entity-registry-settings-editor.ts index 314e7c9615..cbf04023db 100644 --- a/src/panels/config/entities/entity-registry-settings-editor.ts +++ b/src/panels/config/entities/entity-registry-settings-editor.ts @@ -35,7 +35,7 @@ import type { HaSelectSelectEvent } from "../../../components/ha-select"; import "../../../components/ha-state-icon"; import "../../../components/ha-switch"; import type { HaSwitch } from "../../../components/ha-switch"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; import { CAMERA_ORIENTATIONS, CAMERA_SUPPORT_STREAM, @@ -387,20 +387,21 @@ export class EntityRegistrySettingsEditor extends LitElement { return html` ${this.hideName ? nothing - : html``} + > + `} ${this.hideIcon ? nothing : html` + password-toggle + > ` : nothing} ${domain === "alarm_control_panel" ? html` - + password-toggle + > ` : nothing} ${domain === "calendar" @@ -741,33 +744,33 @@ export class EntityRegistrySettingsEditor extends LitElement { ` : nothing} - -
- - -
-
+ ${domain + "."} + + + ${!this.entry.device_id ? html`): void { @@ -1352,9 +1355,12 @@ export class EntityRegistrySettingsEditor extends LitElement { this._unit_of_measurement = ev.detail.value; } - private _defaultcodeChanged(ev): void { + private _defaultcodeChanged(ev: InputEvent): void { fireEvent(this, "change"); - this._defaultCode = ev.target.value === "" ? null : ev.target.value; + this._defaultCode = + (ev.target as HTMLInputElement).value === "" + ? null + : (ev.target as HTMLInputElement).value; } private _calendarColorChanged(ev: CustomEvent): void { @@ -1590,24 +1596,28 @@ export class EntityRegistrySettingsEditor extends LitElement { :host { display: block; } - ha-textfield.entityId { - --text-field-prefix-padding-right: 0; - --textfield-icon-trailing-padding: 0; + .input-prefix { + color: var(--secondary-text-color); + margin: var(--ha-space-3) 0 0; } - ha-textfield.entityId ha-icon-button { - position: relative; - right: calc(var(--ha-space-2) * -1); + + ha-input.entityId, + ha-input.name { --ha-icon-button-size: 36px; --mdc-icon-size: 20px; - color: var(--secondary-text-color); - inset-inline-start: initial; - inset-inline-end: calc(var(--ha-space-2) * -1); - direction: var(--direction); } + + ha-input.name { + --ha-input-start-max-width: 35%; + } + ha-input.entityId ha-icon-button:last-child { + margin-inline-start: 0; + } + ha-md-list-item ha-select { width: auto; } - ha-textfield, + ha-input, ha-icon-picker, ha-select, ha-area-picker { diff --git a/src/panels/config/helpers/forms/ha-counter-form.ts b/src/panels/config/helpers/forms/ha-counter-form.ts index 3f289d673b..2ed19d4f65 100644 --- a/src/panels/config/helpers/forms/ha-counter-form.ts +++ b/src/panels/config/helpers/forms/ha-counter-form.ts @@ -6,7 +6,7 @@ import "../../../../components/ha-expansion-panel"; import "../../../../components/ha-icon-picker"; import "../../../../components/ha-switch"; import type { HaSwitch } from "../../../../components/ha-switch"; -import "../../../../components/ha-textfield"; +import "../../../../components/input/ha-input"; import type { Counter } from "../../../../data/counter"; import { haStyle } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; @@ -71,23 +71,22 @@ class HaCounterForm extends LitElement { return html`
- + > - - + - + + > - + >
- + > - + > - + > - + > - - + + >
- + > - + >
`; @@ -227,10 +226,15 @@ class HaInputNumberForm extends LitElement { .form { color: var(--primary-text-color); } + ha-input { + --ha-input-padding-bottom: 0; + } - ha-textfield { + ha-icon-picker, + ha-input:not([required]) { display: block; - margin-bottom: 8px; + margin-bottom: var(--ha-space-5); + --ha-input-padding-bottom: 0; } `, ]; diff --git a/src/panels/config/helpers/forms/ha-input_select-form.ts b/src/panels/config/helpers/forms/ha-input_select-form.ts index 79a9090448..7560d2d51b 100644 --- a/src/panels/config/helpers/forms/ha-input_select-form.ts +++ b/src/panels/config/helpers/forms/ha-input_select-form.ts @@ -1,4 +1,4 @@ -import { mdiDelete, mdiDragHorizontalVariant } from "@mdi/js"; +import { mdiDelete, mdiDragHorizontalVariant, mdiPlus } from "@mdi/js"; import type { CSSResultGroup } from "lit"; import { LitElement, css, html, nothing } from "lit"; import { customElement, property, query, state } from "lit/decorators"; @@ -10,8 +10,9 @@ import "../../../../components/ha-icon-picker"; import "../../../../components/ha-list"; import "../../../../components/ha-list-item"; import "../../../../components/ha-sortable"; -import "../../../../components/ha-textfield"; -import type { HaTextField } from "../../../../components/ha-textfield"; +import "../../../../components/ha-svg-icon"; +import "../../../../components/input/ha-input"; +import type { HaInput } from "../../../../components/input/ha-input"; import type { InputSelect } from "../../../../data/input_select"; import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; import { haStyle } from "../../../../resources/styles"; @@ -33,7 +34,7 @@ class HaInputSelectForm extends LitElement { @state() private _options: string[] = []; - @query("#option_input", true) private _optionInput?: HaTextField; + @query("#option_input", true) private _optionInput?: HaInput; private _optionMoved(ev: CustomEvent): void { ev.stopPropagation(); @@ -75,9 +76,9 @@ class HaInputSelectForm extends LitElement { return html`
- + > ` ) - : html` - - ${this.hass!.localize( - "ui.dialogs.helper_settings.input_select.no_options" - )} - - `} + : nothing}
- + > ${this.hass!.localize( "ui.dialogs.helper_settings.input_select.add" - )} + )} + +
`; @@ -244,29 +239,27 @@ class HaInputSelectForm extends LitElement { .option { border: 1px solid var(--divider-color); border-radius: var(--ha-border-radius-sm); - margin-top: 4px; + margin-top: var(--ha-space-1); --ha-icon-button-size: 24px; --mdc-ripple-color: transparent; - --mdc-list-side-padding: 16px; + --mdc-list-side-padding: var(--ha-space-4); cursor: default; background-color: var(--card-background-color); } - ha-textfield { - display: block; - margin-bottom: 8px; + ha-input { + --ha-input-padding-bottom: 0; } #option_input { - margin-top: 8px; + margin-top: var(--ha-space-2); } .header { - margin-top: 8px; - margin-bottom: 8px; + margin-top: var(--ha-space-2); } .handle { cursor: move; /* fallback if grab cursor is unsupported */ cursor: grab; - padding-right: 12px; - padding-inline-end: 12px; + padding-right: var(--ha-space-3); + padding-inline-end: var(--ha-space-3); padding-inline-start: initial; } .handle ha-svg-icon { @@ -277,6 +270,14 @@ class HaInputSelectForm extends LitElement { display: flex; align-items: center; } + ha-icon-picker { + display: block; + margin-bottom: var(--ha-space-5); + } + ha-button { + margin-inline-start: var(--ha-space-3); + margin-top: var(--ha-space-1); + } `, ]; } diff --git a/src/panels/config/helpers/forms/ha-input_text-form.ts b/src/panels/config/helpers/forms/ha-input_text-form.ts index 1036e25d27..25ffce0ce4 100644 --- a/src/panels/config/helpers/forms/ha-input_text-form.ts +++ b/src/panels/config/helpers/forms/ha-input_text-form.ts @@ -8,7 +8,7 @@ import "../../../../components/ha-formfield"; import "../../../../components/ha-icon-picker"; import "../../../../components/ha-radio"; import type { HaRadio } from "../../../../components/ha-radio"; -import "../../../../components/ha-textfield"; +import "../../../../components/input/ha-input"; import type { InputText } from "../../../../data/input_text"; import { haStyle } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; @@ -68,21 +68,21 @@ class HaInputTextForm extends LitElement { return html`
- + > - - + + >
${this.hass.localize("ui.dialogs.helper_settings.input_text.mode")}
- + >
`; @@ -205,13 +205,16 @@ class HaInputTextForm extends LitElement { .row { padding: 16px 0; } - ha-textfield, - ha-icon-picker { - display: block; - margin: 8px 0; + ha-input { + --ha-input-padding-bottom: 0; } - ha-expansion-panel { - margin-top: 16px; + ha-icon-picker, + ha-input:not([required]) { + display: block; + margin-bottom: var(--ha-space-5); + } + ha-expansion-panel ha-input:first-child { + margin-top: var(--ha-space-4); } `, ]; diff --git a/src/panels/config/helpers/forms/ha-schedule-form.ts b/src/panels/config/helpers/forms/ha-schedule-form.ts index 13b593888d..6789690723 100644 --- a/src/panels/config/helpers/forms/ha-schedule-form.ts +++ b/src/panels/config/helpers/forms/ha-schedule-form.ts @@ -13,7 +13,7 @@ import { formatTime24h } from "../../../../common/datetime/format_time"; import { useAmPm } from "../../../../common/datetime/use_am_pm"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-icon-picker"; -import "../../../../components/ha-textfield"; +import "../../../../components/input/ha-input"; import type { Schedule, ScheduleDay } from "../../../../data/schedule"; import { weekdays } from "../../../../data/schedule"; import { TimeZone } from "../../../../data/translation"; @@ -121,23 +121,22 @@ class HaScheduleForm extends LitElement { return html`
- + > ${this._error}` : nothing} - + > ${isNew ? html` - + > ` : nothing} diff --git a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-apple-home.ts b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-apple-home.ts index c5413bf3af..21dee5b2ad 100644 --- a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-apple-home.ts +++ b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-apple-home.ts @@ -4,7 +4,7 @@ import { fireEvent } from "../../../../../../common/dom/fire_event"; import "../../../../../../components/ha-icon-next"; import "../../../../../../components/ha-md-list-item"; import "../../../../../../components/ha-md-list"; -import "../../../../../../components/ha-textfield"; +import "../../../../../../components/input/ha-input"; import type { HomeAssistant } from "../../../../../../types"; import { sharedStyles } from "./matter-add-device-shared-styles"; @@ -54,19 +54,19 @@ class MatterAddDeviceAppleHome extends LitElement { "ui.dialogs.matter-add-device.apple_home.code_instructions" )}

- + >
`; } - private _onCodeChanged(ev: any) { - const value = ev.currentTarget.value; + private _onCodeChanged(ev: InputEvent) { + const value = (ev.target as HTMLInputElement).value; this._code = value; fireEvent(this, "pairing-code-changed", { code: value }); } diff --git a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-generic.ts b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-generic.ts index 97b204cff8..794db41c32 100644 --- a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-generic.ts +++ b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-generic.ts @@ -4,7 +4,7 @@ import { fireEvent } from "../../../../../../common/dom/fire_event"; import "../../../../../../components/ha-icon-next"; import "../../../../../../components/ha-md-list-item"; import "../../../../../../components/ha-md-list"; -import "../../../../../../components/ha-textfield"; +import "../../../../../../components/input/ha-input"; import type { HomeAssistant } from "../../../../../../types"; import { sharedStyles } from "./matter-add-device-shared-styles"; @@ -22,19 +22,19 @@ class MatterAddDeviceGeneric extends LitElement { "ui.dialogs.matter-add-device.generic.code_instructions" )}

- + >
`; } - private _onCodeChanged(ev: any) { - const value = ev.currentTarget.value; + private _onCodeChanged(ev: InputEvent) { + const value = (ev.target as HTMLInputElement).value; this._code = value; fireEvent(this, "pairing-code-changed", { code: value }); } diff --git a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-google-home-fallback.ts b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-google-home-fallback.ts index 4da89ef6c1..151a38ad56 100644 --- a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-google-home-fallback.ts +++ b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-google-home-fallback.ts @@ -4,7 +4,7 @@ import { fireEvent } from "../../../../../../common/dom/fire_event"; import "../../../../../../components/ha-icon-next"; import "../../../../../../components/ha-md-list-item"; import "../../../../../../components/ha-md-list"; -import "../../../../../../components/ha-textfield"; +import "../../../../../../components/input/ha-input"; import type { HomeAssistant } from "../../../../../../types"; import { sharedStyles } from "./matter-add-device-shared-styles"; @@ -59,19 +59,19 @@ class MatterAddDeviceGoogleHomeFallback extends LitElement { `ui.dialogs.matter-add-device.google_home_fallback.code_instructions` )}

- + >
`; } - private _onCodeChanged(ev: any) { - const value = ev.currentTarget.value; + private _onCodeChanged(ev: InputEvent) { + const value = (ev.target as HTMLInputElement).value; this._code = value; fireEvent(this, "pairing-code-changed", { code: value }); } diff --git a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-shared-styles.ts b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-shared-styles.ts index 721e8514be..2f0bcbfe96 100644 --- a/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-shared-styles.ts +++ b/src/panels/config/integrations/integration-panels/matter/matter-add-device/matter-add-device-shared-styles.ts @@ -29,7 +29,7 @@ export const sharedStyles = css` --md-list-item-trailing-space: var(--horizontal-padding, 16px); margin-bottom: 16px; } - ha-textfield { + ha-input { width: 100%; } `; diff --git a/src/panels/config/integrations/integration-panels/mqtt/mqtt-config-panel.ts b/src/panels/config/integrations/integration-panels/mqtt/mqtt-config-panel.ts index cc3878319b..361aa2d16f 100644 --- a/src/panels/config/integrations/integration-panels/mqtt/mqtt-config-panel.ts +++ b/src/panels/config/integrations/integration-panels/mqtt/mqtt-config-panel.ts @@ -8,6 +8,7 @@ import "../../../../../components/ha-code-editor"; import "../../../../../components/ha-formfield"; import type { HaSelectSelectEvent } from "../../../../../components/ha-select"; import "../../../../../components/ha-switch"; +import "../../../../../components/input/ha-input"; import { getConfigEntries } from "../../../../../data/config_entries"; import type { Action } from "../../../../../data/script"; import { callExecuteScript } from "../../../../../data/service"; @@ -80,11 +81,11 @@ export class MQTTConfigPanel extends LitElement { >
- + >

- + > - + > - + >
${this.hass.localize("ui.panel.config.zha.groups.add_members")} @@ -146,12 +146,12 @@ export class ZHAAddGroupPage extends LitElement { navigate(`/config/zha/group/${group.group_id}`, { replace: true }); } - private _handleGroupIdChange(event) { - this._groupId = event.target.value; + private _handleGroupIdChange(event: InputEvent) { + this._groupId = (event.target as HTMLInputElement).value; } - private _handleNameChange(event) { - this._groupName = event.target.value || ""; + private _handleNameChange(event: InputEvent) { + this._groupName = (event.target as HTMLInputElement).value || ""; } static get styles(): CSSResultGroup { diff --git a/src/panels/config/integrations/integration-panels/zha/zha-cluster-attributes.ts b/src/panels/config/integrations/integration-panels/zha/zha-cluster-attributes.ts index 6bfc859f0b..cd8e70c618 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-cluster-attributes.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-cluster-attributes.ts @@ -6,7 +6,7 @@ import "../../../../../components/buttons/ha-progress-button"; import "../../../../../components/ha-card"; import "../../../../../components/ha-select"; import type { HaSelectSelectEvent } from "../../../../../components/ha-select"; -import "../../../../../components/ha-textfield"; +import "../../../../../components/input/ha-input"; import { forwardHaptic } from "../../../../../data/haptics"; import type { Attribute, @@ -86,18 +86,17 @@ export class ZHAClusterAttributes extends LitElement { private _renderAttributeInteractions(): TemplateResult { return html`
- + >
- + >
- + >
- + > { + private async _rename(event: InputEvent): Promise { if (!this.hass || !this.device) { return; } const device = this.device; const oldDeviceName = device.user_given_name || device.name; - const newDeviceName = event.target.value; + const newDeviceName = (event.target as HaInput).value; this.device.user_given_name = newDeviceName; await updateDeviceRegistryEntry(this.hass, device.device_reg_id, { name_by_user: newDeviceName, @@ -234,7 +234,7 @@ class ZHADeviceCard extends SubscribeMixin(LitElement) { ha-card { border: none; } - ha-textfield { + ha-input { width: 100%; } `, diff --git a/src/panels/config/integrations/integration-panels/zha/zha-options-page.ts b/src/panels/config/integrations/integration-panels/zha/zha-options-page.ts index 15537d7ec1..6a73c3e111 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-options-page.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-options-page.ts @@ -6,7 +6,7 @@ import "../../../../../components/ha-card"; import "../../../../../components/ha-md-list"; import "../../../../../components/ha-md-list-item"; import "../../../../../components/ha-select"; -import "../../../../../components/ha-textfield"; +import "../../../../../components/input/ha-input"; import "../../../../../components/ha-switch"; import type { ZHAConfiguration } from "../../../../../data/zha"; import { @@ -139,18 +139,19 @@ class ZHAOptionsPage extends LitElement { "ui.panel.config.zha.configuration_page.default_light_transition_description" )} - + > + s + - + > + s + ` : nothing} @@ -272,7 +274,7 @@ class ZHAOptionsPage extends LitElement { ${this._customBattery ? html` - + > + s + ` : nothing} @@ -440,7 +443,7 @@ class ZHAOptionsPage extends LitElement { } ha-select, - ha-textfield { + ha-input { min-width: 210px; } @@ -451,7 +454,7 @@ class ZHAOptionsPage extends LitElement { @media all and (max-width: 450px) { ha-select, - ha-textfield { + ha-input { min-width: 160px; width: 160px; } diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-custom-param.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-custom-param.ts index 7408a60de1..3697f52473 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-custom-param.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-custom-param.ts @@ -6,7 +6,7 @@ import "../../../../../components/ha-button"; import "../../../../../components/ha-select"; import type { HaSelectSelectEvent } from "../../../../../components/ha-select"; import "../../../../../components/ha-spinner"; -import "../../../../../components/ha-textfield"; +import "../../../../../components/input/ha-input"; import { getZwaveNodeRawConfigParameter, setZwaveNodeRawConfigParameter, @@ -34,14 +34,14 @@ class ZWaveJSCustomParam extends LitElement { protected render() { return html`
- + > - + > - `; + ${item.metadata.unit + ? html`${item.metadata.unit}` + : nothing} + `; } if ( @@ -757,7 +758,7 @@ class ZWaveJSNodeConfig extends LitElement { white-space: normal; } - :host(:not([narrow])) ha-settings-row ha-textfield { + :host(:not([narrow])) ha-settings-row ha-input { text-align: right; } diff --git a/src/panels/config/labels/dialog-label-detail.ts b/src/panels/config/labels/dialog-label-detail.ts index ab45509961..a60e1c0464 100644 --- a/src/panels/config/labels/dialog-label-detail.ts +++ b/src/panels/config/labels/dialog-label-detail.ts @@ -10,7 +10,7 @@ import "../../../components/ha-dialog-footer"; import "../../../components/ha-icon-picker"; import "../../../components/ha-switch"; import "../../../components/ha-textarea"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; import { localizeContext } from "../../../data/context"; import type { LabelRegistryEntryMutableParams } from "../../../data/label/label_registry"; import { DialogMixin } from "../../../dialogs/dialog-mixin"; @@ -70,7 +70,7 @@ class DialogLabelDetail extends DialogMixin( ? html`${this._error}` : ""}
- ( "ui.dialogs.label-detail.required_error_msg" )} required - > + > ( `; } - private _input(ev: Event) { - const target = ev.target as any; - const configValue = target.configValue; + private _input(ev: InputEvent) { + const target = ev.target as HTMLInputElement; + const configValue = (target as any).configValue; this._error = undefined; this[`_${configValue}`] = target.value; @@ -195,14 +195,13 @@ class DialogLabelDetail extends DialogMixin( color: var(--primary-color); } ha-textarea, - ha-textfield, ha-icon-picker, ha-color-picker { display: block; + margin-bottom: var(--ha-space-5); } - ha-color-picker, - ha-textarea { - margin-top: 16px; + ha-input { + --ha-input-padding-bottom: 0; } `, ]; diff --git a/src/panels/config/network/ha-config-url-form.ts b/src/panels/config/network/ha-config-url-form.ts index d770f0df29..28e4033610 100644 --- a/src/panels/config/network/ha-config-url-form.ts +++ b/src/panels/config/network/ha-config-url-form.ts @@ -9,7 +9,6 @@ import "../../../components/ha-card"; import "../../../components/ha-md-list-item"; import "../../../components/ha-switch"; import type { HaSwitch } from "../../../components/ha-switch"; -import "../../../components/ha-textfield"; import type { HaInput } from "../../../components/input/ha-input"; import "../../../components/input/ha-input-copy"; import type { HaInputCopy } from "../../../components/input/ha-input-copy"; @@ -44,10 +43,10 @@ class ConfigUrlForm extends SubscribeMixin(LitElement) { @state() private _cloudChecked = false; @query('[data-name="external_url"]') - private _externalUrlField?: HaInput; + private _externalUrlField?: HaInputCopy; @query('[data-name="internal_url"]') - private _internalUrlField?: HaInput; + private _internalUrlField?: HaInputCopy; protected hassSubscribe() { return [ diff --git a/src/panels/config/network/supervisor-hostname.ts b/src/panels/config/network/supervisor-hostname.ts index 1ae40855b9..3080806be6 100644 --- a/src/panels/config/network/supervisor-hostname.ts +++ b/src/panels/config/network/supervisor-hostname.ts @@ -8,7 +8,7 @@ import "../../../components/ha-expansion-panel"; import "../../../components/ha-icon-button"; import "../../../components/ha-radio"; import "../../../components/ha-settings-row"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; import { extractApiErrorMessage } from "../../../data/hassio/common"; import { changeHostOptions, @@ -55,13 +55,13 @@ export class HassioHostname extends LitElement { "ui.panel.config.network.supervisor.hostname.description" )}

- - +
${this._error ? html`
${this._error}
` : ""}
- + > + > ha-assist-chip) { - margin-top: var(--ha-space-4); + margin-bottom: var(--ha-space-5); } ha-alert { display: block; @@ -379,6 +370,9 @@ class DialogSceneSave extends LitElement { ha-suggest-with-ai-button { margin: var(--ha-space-2) var(--ha-space-4); } + ha-input { + --ha-input-padding-bottom: 0; + } `, ]; } diff --git a/src/panels/config/tags/dialog-tag-detail.ts b/src/panels/config/tags/dialog-tag-detail.ts index a68c73d603..b1570056d6 100644 --- a/src/panels/config/tags/dialog-tag-detail.ts +++ b/src/panels/config/tags/dialog-tag-detail.ts @@ -2,18 +2,19 @@ import type { CSSResultGroup } from "lit"; import { LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../common/dom/fire_event"; -import { documentationUrl } from "../../../util/documentation-url"; import "../../../components/ha-alert"; import "../../../components/ha-button"; +import "../../../components/ha-dialog"; import "../../../components/ha-dialog-footer"; import "../../../components/ha-qr-code"; import "../../../components/ha-switch"; -import "../../../components/ha-textfield"; -import "../../../components/ha-dialog"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import type { Tag, UpdateTagParams } from "../../../data/tag"; import type { HassDialog } from "../../../dialogs/make-dialog-manager"; import { haStyleDialog } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; +import { documentationUrl } from "../../../util/documentation-url"; import type { TagDetailDialogParams } from "./show-dialog-tag-detail"; @customElement("dialog-tag-detail") @@ -85,13 +86,7 @@ class DialogTagDetail ? html`${this._error}` : ""}
- ${this._params.entry - ? html`${this.hass!.localize( - "ui.panel.config.tag.detail.tag_id" - )}: - ${this._params.entry.id}` - : ""} - - ${!this._params.entry - ? html`` - : ""} + > +
${this._params.entry ? html` @@ -187,9 +181,9 @@ class DialogTagDetail `; } - private _valueChanged(ev: Event) { - const target = ev.target as any; - const configValue = target.configValue; + private _valueChanged(ev: InputEvent) { + const target = ev.target as HaInput; + const configValue = (target as any).configValue; this._error = undefined; this[`_${configValue}`] = target.value; @@ -246,9 +240,11 @@ class DialogTagDetail #qr { text-align: center; } - ha-textfield { - display: block; - margin: 8px 0; + ha-input { + --ha-input-padding-bottom: 0; + } + ha-input:not([required]) { + margin-bottom: var(--ha-space-5); } ::slotted(img) { height: 100%; diff --git a/src/panels/config/users/dialog-user-detail.ts b/src/panels/config/users/dialog-user-detail.ts index e8fd3164ba..d725d383de 100644 --- a/src/panels/config/users/dialog-user-detail.ts +++ b/src/panels/config/users/dialog-user-detail.ts @@ -5,14 +5,15 @@ import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../common/dom/fire_event"; import "../../../components/ha-alert"; import "../../../components/ha-button"; +import "../../../components/ha-dialog"; import "../../../components/ha-dialog-footer"; import "../../../components/ha-icon-button"; import "../../../components/ha-label"; import "../../../components/ha-md-list-item"; import "../../../components/ha-svg-icon"; import "../../../components/ha-switch"; -import "../../../components/ha-textfield"; -import "../../../components/ha-dialog"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import { adminChangeUsername } from "../../../data/auth"; import { computeUserBadges, @@ -103,14 +104,14 @@ class DialogUserDetail extends LitElement { ${ !user.system_generated ? html` - + > ${this.hass.localize( @@ -268,9 +269,9 @@ class DialogUserDetail extends LitElement { `; } - private _nameChanged(ev) { + private _nameChanged(ev: InputEvent) { this._error = undefined; - this._name = ev.target.value; + this._name = (ev.target as HaInput).value ?? ""; } private _adminChanged(ev): void { @@ -398,9 +399,6 @@ class DialogUserDetail extends LitElement { .secondary { color: var(--secondary-text-color); } - ha-textfield { - display: block; - } ha-md-list-item { --md-list-item-leading-space: 0; --md-list-item-trailing-space: 0; diff --git a/src/panels/config/voice-assistants/cloud-google-pref.ts b/src/panels/config/voice-assistants/cloud-google-pref.ts index 2c504b303c..44bff4fb3d 100644 --- a/src/panels/config/voice-assistants/cloud-google-pref.ts +++ b/src/panels/config/voice-assistants/cloud-google-pref.ts @@ -10,8 +10,8 @@ import "../../../components/ha-button"; import "../../../components/ha-md-list-item"; import "../../../components/ha-switch"; import type { HaSwitch } from "../../../components/ha-switch"; -import "../../../components/ha-textfield"; -import type { HaTextField } from "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import type { CloudStatusLoggedIn } from "../../../data/cloud"; import { updateCloudPref } from "../../../data/cloud"; import type { ExposeEntitySettings } from "../../../data/expose"; @@ -208,7 +208,7 @@ export class CloudGooglePref extends LitElement { - + > ` : nothing} `} @@ -292,8 +292,8 @@ export class CloudGooglePref extends LitElement { } } - private async _pinChanged(ev) { - const input = ev.target as HaTextField; + private async _pinChanged(ev: InputEvent) { + const input = ev.target as HaInput; try { await updateCloudPref(this.hass, { [input.id]: input.value || null, @@ -336,9 +336,8 @@ export class CloudGooglePref extends LitElement { --md-list-item-trailing-space: 0; --md-item-overflow: visible; } - ha-textfield { + ha-input { width: 250px; - display: block; margin-top: 8px; } .card-actions { diff --git a/src/panels/config/voice-assistants/debug/assist-pipeline-run-debug.ts b/src/panels/config/voice-assistants/debug/assist-pipeline-run-debug.ts index da9ff7f70d..d2e34211df 100644 --- a/src/panels/config/voice-assistants/debug/assist-pipeline-run-debug.ts +++ b/src/panels/config/voice-assistants/debug/assist-pipeline-run-debug.ts @@ -8,8 +8,8 @@ import "../../../../components/ha-button"; import "../../../../components/ha-checkbox"; import type { HaCheckbox } from "../../../../components/ha-checkbox"; import "../../../../components/ha-formfield"; -import "../../../../components/ha-textfield"; -import type { HaTextField } from "../../../../components/ha-textfield"; +import "../../../../components/input/ha-input"; +import type { HaInput } from "../../../../components/input/ha-input"; import type { PipelineRun, PipelineRunOptions, @@ -40,7 +40,7 @@ export class AssistPipelineRunDebug extends LitElement { private _continueConversationCheckbox!: HaCheckbox; @query("#continue-conversation-text") - private _continueConversationTextField?: HaTextField; + private _continueConversationTextField?: HaInput; private _audioBuffer?: Int16Array[]; @@ -129,14 +129,14 @@ export class AssistPipelineRunDebug extends LitElement { ` : this._pipelineRuns[0].init_options!.start_stage === "intent" ? html` - + > + > `} ${stateObj.attributes.code_format !== FORMAT_NUMBER || defaultCode ? nothing @@ -335,7 +335,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard { } private _handleInput(e: Event): void { - this._value = (e.currentTarget as HaTextField).value; + this._value = (e.currentTarget as HaInput).value; } private _handlePadClick(e: MouseEvent): void { @@ -402,26 +402,26 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard { } } - ha-textfield { - display: block; - margin: 8px; + ha-input { + margin: var(--ha-space-2); max-width: 150px; text-align: center; + --ha-input-padding-bottom: 0; } .state { - margin-left: 16px; - margin-inline-start: 16px; + margin-left: var(--ha-space-4); + margin-inline-start: var(--ha-space-4); margin-inline-end: initial; position: relative; - bottom: 16px; + bottom: var(--ha-space-4); color: var(--alarm-state-color); animation: none; } .keypad { --keypad-columns: 3; - padding: 12px; + padding: var(--ha-space-3); display: grid; grid-template-columns: repeat(var(--keypad-columns), auto); grid-auto-rows: auto; @@ -448,10 +448,11 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard { display: flex; flex-wrap: wrap; justify-content: center; + align-items: center; } .actions ha-button { - margin: 0 4px 4px; + margin: var(--ha-space-1); } `; } diff --git a/src/panels/lovelace/components/hui-action-editor.ts b/src/panels/lovelace/components/hui-action-editor.ts index 6c588592c3..315be2994a 100644 --- a/src/panels/lovelace/components/hui-action-editor.ts +++ b/src/panels/lovelace/components/hui-action-editor.ts @@ -12,6 +12,8 @@ import "../../../components/ha-help-tooltip"; import "../../../components/ha-navigation-picker"; import type { HaSelectSelectEvent } from "../../../components/ha-select"; import "../../../components/ha-service-control"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import type { ActionConfig, CallServiceActionConfig, @@ -20,7 +22,6 @@ import type { } from "../../../data/lovelace/config/action"; import type { ServiceAction } from "../../../data/script"; import type { HomeAssistant } from "../../../types"; -import type { EditorTarget } from "../editor/types"; export type UiAction = Exclude; @@ -197,14 +198,14 @@ export class HuiActionEditor extends LitElement { : nothing} ${this.config?.action === "url" ? html` - + > ` : nothing} ${this.config?.action === "call-service" || @@ -276,19 +277,20 @@ export class HuiActionEditor extends LitElement { }); } - private _valueChanged(ev): void { + private _valueChanged(ev: InputEvent): void { ev.stopPropagation(); if (!this.hass) { return; } - const target = ev.target! as EditorTarget; - const value = ev.target.value ?? ev.target.checked; - if (this[`_${target.configValue}`] === value) { + const target = ev.target! as HaInput; + const configValue: string | undefined = (target as any).configValue; + const value = target.value ?? ""; + if (this[`_${configValue}`] === value) { return; } - if (target.configValue) { + if (configValue) { fireEvent(this, "value-changed", { - value: { ...this.config!, [target.configValue!]: value }, + value: { ...this.config!, [configValue]: value }, }); } } @@ -344,7 +346,7 @@ export class HuiActionEditor extends LitElement { direction: var(--direction); } ha-select, - ha-textfield { + ha-input { width: 100%; } ha-service-control, @@ -352,7 +354,7 @@ export class HuiActionEditor extends LitElement { ha-form { display: block; } - ha-textfield, + ha-input, ha-service-control, ha-navigation-picker, ha-form { diff --git a/src/panels/lovelace/editor/config-elements/config-elements-style.ts b/src/panels/lovelace/editor/config-elements/config-elements-style.ts index 2a3b7182c2..d2920d6d9e 100644 --- a/src/panels/lovelace/editor/config-elements/config-elements-style.ts +++ b/src/panels/lovelace/editor/config-elements/config-elements-style.ts @@ -29,7 +29,7 @@ export const configElementStyle = css` } hui-action-editor, ha-select, - ha-textfield, + ha-input, ha-icon-picker { margin-top: 8px; display: block; diff --git a/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts index 633c6fe8f9..cbfa754667 100644 --- a/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts @@ -1,6 +1,7 @@ import type { CSSResultGroup } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; +import memoizeOne from "memoize-one"; import { any, array, @@ -17,7 +18,6 @@ import { type, union, } from "superstruct"; -import memoizeOne from "memoize-one"; import type { HASSDomEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event"; import { customType } from "../../../../common/structs/is-custom-type"; @@ -25,11 +25,13 @@ import "../../../../components/ha-card"; import "../../../../components/ha-formfield"; import "../../../../components/ha-icon"; import "../../../../components/ha-switch"; -import "../../../../components/ha-textfield"; import "../../../../components/ha-theme-picker"; +import "../../../../components/input/ha-input"; import { isCustomType } from "../../../../data/lovelace_custom_cards"; import type { HomeAssistant } from "../../../../types"; +import { computeShowHeaderToggle } from "../../cards/hui-entities-card"; import type { EntitiesCardConfig } from "../../cards/types"; +import { processConfigEntities } from "../../common/process-config-entities"; import { TIMESTAMP_RENDERING_FORMATS } from "../../components/types"; import type { LovelaceRowConfig } from "../../entity-rows/types"; import { headerFooterConfigStructs } from "../../header-footer/structs"; @@ -43,13 +45,11 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct"; import { buttonEntityConfigStruct } from "../structs/button-entity-struct"; import { entitiesConfigStruct } from "../structs/entities-struct"; import type { - EditorTarget, EditDetailElementEvent, + EditorTarget, SubElementEditorConfig, } from "../types"; import { configElementStyle } from "./config-elements-style"; -import { computeShowHeaderToggle } from "../../cards/hui-entities-card"; -import { processConfigEntities } from "../../common/process-config-entities"; const buttonEntitiesRowConfigStruct = object({ type: literal("button"), @@ -249,7 +249,7 @@ export class HuiEntitiesCardEditor return html`
- + > - + >
`; diff --git a/src/panels/lovelace/entity-rows/hui-date-entity-row.ts b/src/panels/lovelace/entity-rows/hui-date-entity-row.ts index be5718e8fe..65dc004f5a 100644 --- a/src/panels/lovelace/entity-rows/hui-date-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-date-entity-row.ts @@ -1,5 +1,5 @@ import type { PropertyValues, TemplateResult } from "lit"; -import { html, LitElement, nothing } from "lit"; +import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import "../../../components/ha-date-input"; import { setDateValue } from "../../../data/date"; @@ -64,6 +64,12 @@ class HuiDateEntityRow extends LitElement implements LovelaceRow { setDateValue(this.hass!, this._config!.entity, ev.detail.value); } } + + static styles = css` + ha-date-input { + max-width: 50%; + } + `; } declare global { diff --git a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts index b781d22ab9..ef1590aafd 100644 --- a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.ts @@ -3,7 +3,7 @@ import { LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { debounce } from "../../../common/util/debounce"; import "../../../components/ha-slider"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; import { isUnavailableState } from "../../../data/entity/entity"; import { setValue } from "../../../data/input_text"; import type { HomeAssistant } from "../../../types"; @@ -92,18 +92,20 @@ class HuiInputNumberEntityRow extends LitElement implements LovelaceRow { ` : html`
- - + ${stateObj.attributes.unit_of_measurement || ""} +
`} @@ -124,7 +126,10 @@ class HuiInputNumberEntityRow extends LitElement implements LovelaceRow { min-width: 45px; text-align: end; } - ha-textfield { + ha-input { + width: 100%; + } + ha-input::part(wa-input) { text-align: end; } ha-slider { diff --git a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts index 7763060fc0..f93f4eaa43 100644 --- a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts @@ -1,7 +1,8 @@ import type { PropertyValues } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity"; import { setValue } from "../../../data/input_text"; import type { HomeAssistant } from "../../../types"; @@ -50,7 +51,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow { .config=${this._config} hide-name > - + .placeholder=${this.hass.localize("ui.card.text.empty_value")} + > `; } - private _selectedValueChanged(ev): void { + private _selectedValueChanged(ev: InputEvent): void { const stateObj = this.hass!.states[this._config!.entity]; + const target = ev.target as HaInput; - const newValue = ev.target.value; + const newValue = target.value ?? ""; // Filter out invalid text states if (newValue && isUnavailableState(newValue)) { - ev.target.value = stateObj.state; + target.value = stateObj.state; return; } @@ -81,7 +83,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow { setValue(this.hass!, stateObj.entity_id, newValue); } - ev.target.blur(); + target.blur(); } static styles = css` @@ -89,7 +91,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow { display: flex; align-items: center; } - ha-textfield { + ha-input { width: 100%; } `; diff --git a/src/panels/lovelace/entity-rows/hui-number-entity-row.ts b/src/panels/lovelace/entity-rows/hui-number-entity-row.ts index c22f275d7c..4ce0b5d878 100644 --- a/src/panels/lovelace/entity-rows/hui-number-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-number-entity-row.ts @@ -3,7 +3,8 @@ import { LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { debounce } from "../../../common/util/debounce"; import "../../../components/ha-slider"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import { UNAVAILABLE } from "../../../data/entity/entity"; import { setValue } from "../../../data/input_text"; import type { HomeAssistant } from "../../../types"; @@ -96,18 +97,21 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow { ` : html`
- + > + ${stateObj.attributes.unit_of_measurement} +
`} @@ -128,7 +132,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow { min-width: 45px; text-align: end; } - ha-textfield { + ha-input::part(wa-input) { text-align: end; direction: ltr !important; } @@ -166,11 +170,11 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow { } } - private _selectedValueChanged(ev): void { + private _selectedValueChanged(ev: InputEvent): void { const stateObj = this.hass!.states[this._config!.entity]; - if (ev.target.value !== stateObj.state) { - setValue(this.hass!, stateObj.entity_id, ev.target.value!); + if ((ev.target as HaInput).value !== stateObj.state) { + setValue(this.hass!, stateObj.entity_id, (ev.target as HaInput).value!); } } } diff --git a/src/panels/lovelace/entity-rows/hui-text-entity-row.ts b/src/panels/lovelace/entity-rows/hui-text-entity-row.ts index 0945e5b69c..a6a0475a46 100644 --- a/src/panels/lovelace/entity-rows/hui-text-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-text-entity-row.ts @@ -1,7 +1,8 @@ import type { PropertyValues } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; -import "../../../components/ha-textfield"; +import "../../../components/input/ha-input"; +import type { HaInput } from "../../../components/input/ha-input"; import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity"; import type { TextEntity } from "../../../data/text"; import { setValue } from "../../../data/text"; @@ -53,7 +54,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow { .config=${this._config} hide-name > - + .placeholder=${this.hass!.localize("ui.card.text.empty_value")} + > `; } - private _valueChanged(ev): void { + private _valueChanged(ev: InputEvent): void { const stateObj = this.hass!.states[this._config!.entity] as TextEntity; - const newValue = ev.target.value; + const target = ev.target as HaInput; + const newValue = target.value ?? ""; // Filter out invalid text states if (newValue && isUnavailableState(newValue)) { - ev.target.value = stateObj.state; + target.value = stateObj.state; return; } @@ -83,7 +85,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow { setValue(this.hass!, stateObj.entity_id, newValue); } - ev.target.blur(); + target.blur(); } static styles = css` @@ -91,7 +93,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow { display: flex; align-items: center; } - ha-textfield { + ha-input { width: 100%; } `; diff --git a/src/panels/profile/ha-long-lived-access-token-dialog.ts b/src/panels/profile/ha-long-lived-access-token-dialog.ts index 0746f62ee3..cea77f73f6 100644 --- a/src/panels/profile/ha-long-lived-access-token-dialog.ts +++ b/src/panels/profile/ha-long-lived-access-token-dialog.ts @@ -6,14 +6,14 @@ import { fireEvent } from "../../common/dom/fire_event"; import { copyToClipboard } from "../../common/util/copy-clipboard"; import { withViewTransition } from "../../common/util/view-transition"; import "../../components/ha-alert"; -import "../../components/ha-textfield"; import "../../components/ha-button"; +import "../../components/ha-dialog"; import "../../components/ha-dialog-footer"; import "../../components/ha-svg-icon"; -import "../../components/ha-dialog"; +import "../../components/input/ha-input"; import type { HomeAssistant } from "../../types"; -import type { LongLivedAccessTokenDialogParams } from "./show-long-lived-access-token-dialog"; import { showToast } from "../../util/toast"; +import type { LongLivedAccessTokenDialogParams } from "./show-long-lived-access-token-dialog"; const QR_LOGO_URL = "/static/icons/favicon-192x192.png"; @@ -98,12 +98,12 @@ export class HaLongLivedAccessTokenDialog extends LitElement { )}

- + readonly + > ` : html` - + > `}
@@ -285,15 +285,12 @@ export class HaLongLivedAccessTokenDialog extends LitElement { gap: var(--ha-space-2); align-items: center; } - .token-row ha-textfield { + .token-row ha-input { flex: 1; } p { margin: 0; } - ha-textfield { - display: block; - } `, ]; } diff --git a/src/panels/profile/ha-pick-theme-row.ts b/src/panels/profile/ha-pick-theme-row.ts index a4f07951e8..6be63e86f9 100644 --- a/src/panels/profile/ha-pick-theme-row.ts +++ b/src/panels/profile/ha-pick-theme-row.ts @@ -7,10 +7,10 @@ import "../../components/ha-button"; import "../../components/ha-formfield"; import "../../components/ha-radio"; import type { HaRadio } from "../../components/ha-radio"; -import type { HaSelectSelectEvent } from "../../components/ha-select"; import "../../components/ha-select"; +import type { HaSelectSelectEvent } from "../../components/ha-select"; import "../../components/ha-settings-row"; -import "../../components/ha-textfield"; +import "../../components/input/ha-input"; import { saveThemePreferences, subscribeThemePreferences, @@ -153,7 +153,7 @@ export class HaPickThemeRow extends SubscribeMixin(LitElement) { ${curTheme === HOME_ASSISTANT_THEME ? html`
- - + + > ${themeSettings?.primaryColor || themeSettings?.accentColor ? html` - + >
${this._completedTime ? html`
@@ -301,8 +302,8 @@ class DialogTodoItemEditor extends LitElement { this._checked = ev.target.checked; } - private _handleSummaryChanged(ev) { - this._summary = ev.target.value; + private _handleSummaryChanged(ev: InputEvent) { + this._summary = (ev.target as HaInput).value ?? ""; } private _handleDescriptionChanged(ev) { @@ -438,7 +439,9 @@ class DialogTodoItemEditor extends LitElement { display: block; margin-bottom: 16px; } - ha-textfield, + ha-input { + width: 100%; + } ha-textarea { display: block; width: 100%; diff --git a/src/state-summary/state-card-input_number.ts b/src/state-summary/state-card-input_number.ts index 6b4e26bd07..408c65bc6d 100644 --- a/src/state-summary/state-card-input_number.ts +++ b/src/state-summary/state-card-input_number.ts @@ -1,11 +1,11 @@ import type { HassEntity } from "home-assistant-js-websocket"; import type { TemplateResult } from "lit"; -import { css, html, LitElement } from "lit"; +import { css, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { debounce } from "../common/util/debounce"; import "../components/entity/state-info"; import "../components/ha-slider"; -import "../components/ha-textfield"; +import "../components/input/ha-input"; import { isUnavailableState } from "../data/entity/entity"; import { setValue } from "../data/input_text"; import type { HomeAssistant } from "../types"; @@ -71,18 +71,22 @@ class StateCardInputNumber extends LitElement { ` : html`
- - + ${this.stateObj.attributes.unit_of_measurement + ? html`${this.stateObj.attributes.unit_of_measurement}` + : nothing} +
`} `; @@ -102,7 +106,7 @@ class StateCardInputNumber extends LitElement { min-width: 45px; text-align: end; } - ha-textfield { + ha-input::part(wa-input) { text-align: end; } ha-slider { diff --git a/src/state-summary/state-card-input_text.ts b/src/state-summary/state-card-input_text.ts index 29f4bf98be..90349d6524 100644 --- a/src/state-summary/state-card-input_text.ts +++ b/src/state-summary/state-card-input_text.ts @@ -2,11 +2,12 @@ import type { HassEntity } from "home-assistant-js-websocket"; import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit"; import { css, html, LitElement } from "lit"; import { customElement, property, state } from "lit/decorators"; -import "../components/entity/state-info"; -import "../components/ha-textfield"; -import type { HomeAssistant } from "../types"; -import { haStyle } from "../resources/styles"; import { stopPropagation } from "../common/dom/stop_propagation"; +import "../components/entity/state-info"; +import "../components/input/ha-input"; +import type { HaInput } from "../components/input/ha-input"; +import { haStyle } from "../resources/styles"; +import type { HomeAssistant } from "../types"; @customElement("state-card-input_text") class StateCardInputText extends LitElement { @@ -26,7 +27,7 @@ class StateCardInputText extends LitElement { .stateObj=${this.stateObj} .inDialog=${this.inDialog} > - +
`; } @@ -49,8 +50,8 @@ class StateCardInputText extends LitElement { } } - private _onInput(ev) { - this.value = ev.target.value; + private _onInput(ev: InputEvent) { + this.value = (ev.target as HaInput).value ?? ""; } private async _selectedValueChanged() { @@ -67,9 +68,9 @@ class StateCardInputText extends LitElement { return [ haStyle, css` - ha-textfield { - margin-left: 16px; - margin-inline-start: 16px; + ha-input { + margin-left: var(--ha-space-4); + margin-inline-start: var(--ha-space-4); margin-inline-end: initial; } `, diff --git a/src/state-summary/state-card-number.ts b/src/state-summary/state-card-number.ts index 38c1be6a73..15ce8d2501 100644 --- a/src/state-summary/state-card-number.ts +++ b/src/state-summary/state-card-number.ts @@ -1,11 +1,11 @@ import type { HassEntity } from "home-assistant-js-websocket"; import type { CSSResultGroup } from "lit"; -import { css, html, LitElement } from "lit"; +import { css, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { debounce } from "../common/util/debounce"; import "../components/entity/state-info"; import "../components/ha-slider"; -import "../components/ha-textfield"; +import "../components/input/ha-input"; import { isUnavailableState } from "../data/entity/entity"; import { haStyle } from "../resources/styles"; import type { HomeAssistant } from "../types"; @@ -74,18 +74,22 @@ class StateCardNumber extends LitElement {
` : html`
- - + ${this.stateObj.attributes.unit_of_measurement + ? html`${this.stateObj.attributes.unit_of_measurement}` + : nothing} +
`} `; } @@ -146,7 +150,7 @@ class StateCardNumber extends LitElement { min-width: 45px; text-align: end; } - ha-textfield { + ha-input::part(wa-input) { text-align: end; } ha-slider { diff --git a/src/state-summary/state-card-text.ts b/src/state-summary/state-card-text.ts index 17493a1e9d..8b09c070a7 100644 --- a/src/state-summary/state-card-text.ts +++ b/src/state-summary/state-card-text.ts @@ -4,7 +4,8 @@ import { customElement, property } from "lit/decorators"; import { stopPropagation } from "../common/dom/stop_propagation"; import { computeStateName } from "../common/entity/compute_state_name"; import "../components/entity/state-badge"; -import "../components/ha-textfield"; +import "../components/input/ha-input"; +import type { HaInput } from "../components/input/ha-input"; import { isUnavailableState, UNAVAILABLE } from "../data/entity/entity"; import type { TextEntity } from "../data/text"; import { setValue } from "../data/text"; @@ -19,7 +20,7 @@ class StateCardText extends LitElement { protected render(): TemplateResult { return html` - + .placeholder=${this.hass.localize("ui.card.text.empty_value")} + > `; } - private _valueChanged(ev): void { - const value = ev.target.value; + private _valueChanged(ev: InputEvent): void { + const value = (ev.target as HaInput).value ?? ""; // Filter out invalid text states if (value && isUnavailableState(value)) { - ev.target.value = this.stateObj.state; + (ev.target as HaInput).value = this.stateObj.state; return; } @@ -60,7 +61,7 @@ class StateCardText extends LitElement { margin-top: 10px; } - ha-textfield { + ha-input { width: 100%; } `; diff --git a/src/translations/en.json b/src/translations/en.json index 12f6582d6e..828fdcb861 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -295,7 +295,7 @@ "up_to_date": "Up-to-date" }, "text": { - "emtpy_value": "(empty value)" + "empty_value": "(empty value)" }, "timer": { "actions": {