Replace more polymer paper inputs and remove paper-input style attributes (#18929)

This commit is contained in:
Simon Lamon 2023-12-18 13:05:56 +01:00 committed by GitHub
parent ff9d179c13
commit f2745747ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 59 additions and 69 deletions

View File

@ -1,5 +1,4 @@
import "@material/mwc-button"; import "@material/mwc-button";
import "@polymer/paper-input/paper-textarea";
import { import {
css, css,
CSSResultGroup, CSSResultGroup,
@ -20,6 +19,7 @@ import { haStyle } from "../../../../../resources/styles";
import { HomeAssistant, Route } from "../../../../../types"; import { HomeAssistant, Route } from "../../../../../types";
import { zhaTabs } from "./zha-config-dashboard"; import { zhaTabs } from "./zha-config-dashboard";
import "./zha-device-pairing-status-card"; import "./zha-device-pairing-status-card";
import "../../../../../components/ha-textarea";
@customElement("zha-add-devices-page") @customElement("zha-add-devices-page")
class ZHAAddDevicesPage extends LitElement { class ZHAAddDevicesPage extends LitElement {
@ -146,13 +146,13 @@ class ZHAAddDevicesPage extends LitElement {
`} `}
</div> </div>
${this._showLogs ${this._showLogs
? html`<paper-textarea ? html`<ha-textarea
readonly readonly
max-rows="10"
class="log" class="log"
value=${this._formattedEvents} autogrow
.value=${this._formattedEvents}
> >
</paper-textarea>` </ha-textarea>`
: ""} : ""}
</hass-tabs-subpage> </hass-tabs-subpage>
`; `;
@ -165,13 +165,6 @@ class ZHAAddDevicesPage extends LitElement {
private _handleMessage(message: any): void { private _handleMessage(message: any): void {
if (message.type === LOG_OUTPUT) { if (message.type === LOG_OUTPUT) {
this._formattedEvents += message.log_entry.message + "\n"; this._formattedEvents += message.log_entry.message + "\n";
if (this.shadowRoot) {
const paperTextArea = this.shadowRoot.querySelector("paper-textarea");
if (paperTextArea) {
const textArea = (paperTextArea.inputElement as any).textarea;
textArea.scrollTop = textArea.scrollHeight;
}
}
} }
if (message.type && DEVICE_MESSAGE_TYPES.includes(message.type)) { if (message.type && DEVICE_MESSAGE_TYPES.includes(message.type)) {
this._discoveredDevices[message.device_info.ieee] = message.device_info; this._discoveredDevices[message.device_info.ieee] = message.device_info;
@ -266,6 +259,9 @@ class ZHAAddDevicesPage extends LitElement {
color: grey; color: grey;
padding-left: 16px; padding-left: 16px;
} }
ha-textarea {
width: 100%;
}
`, `,
]; ];
} }

View File

@ -1,6 +1,4 @@
import "@material/mwc-button"; import "@material/mwc-button";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit"; import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
import { customElement, property, state, query } from "lit/decorators"; import { customElement, property, state, query } from "lit/decorators";
import type { HASSDomEvent } from "../../../../../common/dom/fire_event"; import type { HASSDomEvent } from "../../../../../common/dom/fire_event";
@ -14,8 +12,9 @@ import {
ZHAGroup, ZHAGroup,
} from "../../../../../data/zha"; } from "../../../../../data/zha";
import "../../../../../layouts/hass-subpage"; import "../../../../../layouts/hass-subpage";
import type { ValueChangedEvent, HomeAssistant } from "../../../../../types"; import type { HomeAssistant } from "../../../../../types";
import "../../../ha-config-section"; import "../../../ha-config-section";
import "../../../../../components/ha-textfield";
import "./zha-device-endpoint-data-table"; import "./zha-device-endpoint-data-table";
import type { ZHADeviceEndpointDataTable } from "./zha-device-endpoint-data-table"; import type { ZHADeviceEndpointDataTable } from "./zha-device-endpoint-data-table";
@ -66,14 +65,14 @@ export class ZHAAddGroupPage extends LitElement {
"ui.panel.config.zha.groups.create_group_details" "ui.panel.config.zha.groups.create_group_details"
)} )}
</p> </p>
<paper-input <ha-textfield
type="string" type="string"
.value=${this._groupName} .value=${this._groupName}
@value-changed=${this._handleNameChange} @change=${this._handleNameChange}
placeholder=${this.hass!.localize( .placeholder=${this.hass!.localize(
"ui.panel.config.zha.groups.group_name_placeholder" "ui.panel.config.zha.groups.group_name_placeholder"
)} )}
></paper-input> ></ha-textfield>
<div class="header"> <div class="header">
${this.hass.localize("ui.panel.config.zha.groups.add_members")} ${this.hass.localize("ui.panel.config.zha.groups.add_members")}
@ -139,9 +138,8 @@ export class ZHAAddGroupPage extends LitElement {
navigate(`/config/zha/group/${group.group_id}`, { replace: true }); navigate(`/config/zha/group/${group.group_id}`, { replace: true });
} }
private _handleNameChange(ev: ValueChangedEvent<string>) { private _handleNameChange(event) {
const target = ev.currentTarget as PaperInputElement; this._groupName = event.target.value || "";
this._groupName = target.value || "";
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {

View File

@ -1,5 +1,4 @@
import "@material/mwc-list/mwc-list-item"; import "@material/mwc-list/mwc-list-item";
import "@polymer/paper-input/paper-input";
import { import {
css, css,
CSSResultGroup, CSSResultGroup,
@ -15,6 +14,7 @@ import "../../../../../components/buttons/ha-call-service-button";
import "../../../../../components/buttons/ha-progress-button"; import "../../../../../components/buttons/ha-progress-button";
import "../../../../../components/ha-card"; import "../../../../../components/ha-card";
import "../../../../../components/ha-select"; import "../../../../../components/ha-select";
import "../../../../../components/ha-textfield";
import { forwardHaptic } from "../../../../../data/haptics"; import { forwardHaptic } from "../../../../../data/haptics";
import { import {
Attribute, Attribute,
@ -27,11 +27,7 @@ import {
import { haStyle } from "../../../../../resources/styles"; import { haStyle } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import { formatAsPaddedHex } from "./functions"; import { formatAsPaddedHex } from "./functions";
import { import { ItemSelectedEvent, SetAttributeServiceData } from "./types";
ChangeEvent,
ItemSelectedEvent,
SetAttributeServiceData,
} from "./types";
@customElement("zha-cluster-attributes") @customElement("zha-cluster-attributes")
export class ZHAClusterAttributes extends LitElement { export class ZHAClusterAttributes extends LitElement {
@ -101,24 +97,28 @@ export class ZHAClusterAttributes extends LitElement {
private _renderAttributeInteractions(): TemplateResult { private _renderAttributeInteractions(): TemplateResult {
return html` return html`
<div class="input-text"> <div class="input-text">
<paper-input <ha-textfield
label=${this.hass!.localize("ui.panel.config.zha.common.value")} .label=${this.hass!.localize("ui.panel.config.zha.common.value")}
type="string" type="string"
.value=${this._attributeValue} .value=${this._attributeValue}
@value-changed=${this._onAttributeValueChanged} @change=${this._onAttributeValueChanged}
placeholder=${this.hass!.localize("ui.panel.config.zha.common.value")} .placeholder=${this.hass!.localize(
></paper-input> "ui.panel.config.zha.common.value"
)}
></ha-textfield>
</div> </div>
<div class="input-text"> <div class="input-text">
<paper-input <ha-textfield
label=${this.hass!.localize( .label=${this.hass!.localize(
"ui.panel.config.zha.common.manufacturer_code_override" "ui.panel.config.zha.common.manufacturer_code_override"
)} )}
type="number" type="number"
.value=${this._manufacturerCodeOverride} .value=${this._manufacturerCodeOverride}
@value-changed=${this._onManufacturerCodeOverrideChanged} @change=${this._onManufacturerCodeOverrideChanged}
placeholder=${this.hass!.localize("ui.panel.config.zha.common.value")} .placeholder=${this.hass!.localize(
></paper-input> "ui.panel.config.zha.common.value"
)}
></ha-textfield>
</div> </div>
<div class="card-actions"> <div class="card-actions">
<ha-progress-button <ha-progress-button
@ -197,13 +197,13 @@ export class ZHAClusterAttributes extends LitElement {
}; };
} }
private _onAttributeValueChanged(value: ChangeEvent): void { private _onAttributeValueChanged(event): void {
this._attributeValue = value.detail!.value; this._attributeValue = event.target!.value;
this._setAttributeServiceData = this._computeSetAttributeServiceData(); this._setAttributeServiceData = this._computeSetAttributeServiceData();
} }
private _onManufacturerCodeOverrideChanged(value: ChangeEvent): void { private _onManufacturerCodeOverrideChanged(event): void {
this._manufacturerCodeOverride = value.detail!.value; this._manufacturerCodeOverride = event.target!.value;
this._setAttributeServiceData = this._computeSetAttributeServiceData(); this._setAttributeServiceData = this._computeSetAttributeServiceData();
} }
@ -238,7 +238,8 @@ export class ZHAClusterAttributes extends LitElement {
margin-top: 16px; margin-top: 16px;
} }
.menu { .menu,
ha-textfield {
width: 100%; width: 100%;
} }

View File

@ -1,5 +1,4 @@
import "@material/mwc-list/mwc-list-item"; import "@material/mwc-list/mwc-list-item";
import "@polymer/paper-input/paper-input";
import { import {
css, css,
CSSResultGroup, CSSResultGroup,
@ -14,6 +13,7 @@ import "../../../../../components/buttons/ha-call-service-button";
import "../../../../../components/ha-card"; import "../../../../../components/ha-card";
import "../../../../../components/ha-form/ha-form"; import "../../../../../components/ha-form/ha-form";
import "../../../../../components/ha-select"; import "../../../../../components/ha-select";
import "../../../../../components/ha-textfield";
import { import {
Cluster, Cluster,
Command, Command,
@ -23,7 +23,7 @@ import {
import { haStyle } from "../../../../../resources/styles"; import { haStyle } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types"; import { HomeAssistant } from "../../../../../types";
import { formatAsPaddedHex } from "./functions"; import { formatAsPaddedHex } from "./functions";
import { ChangeEvent, IssueCommandServiceData } from "./types"; import { IssueCommandServiceData } from "./types";
export class ZHAClusterCommands extends LitElement { export class ZHAClusterCommands extends LitElement {
@property({ attribute: false }) public hass?: HomeAssistant; @property({ attribute: false }) public hass?: HomeAssistant;
@ -88,17 +88,17 @@ export class ZHAClusterCommands extends LitElement {
${this._selectedCommandId !== undefined ${this._selectedCommandId !== undefined
? html` ? html`
<div class="input-text"> <div class="input-text">
<paper-input <ha-textfield
label=${this.hass!.localize( .label=${this.hass!.localize(
"ui.panel.config.zha.common.manufacturer_code_override" "ui.panel.config.zha.common.manufacturer_code_override"
)} )}
type="number" type="number"
.value=${this._manufacturerCodeOverride} .value=${this._manufacturerCodeOverride}
@value-changed=${this._onManufacturerCodeOverrideChanged} @change=${this._onManufacturerCodeOverrideChanged}
placeholder=${this.hass!.localize( .placeholder=${this.hass!.localize(
"ui.panel.config.zha.common.value" "ui.panel.config.zha.common.value"
)} )}
></paper-input> ></ha-textfield>
</div> </div>
<div class="command-form"> <div class="command-form">
<ha-form <ha-form
@ -180,8 +180,8 @@ export class ZHAClusterCommands extends LitElement {
this._computeIssueClusterCommandServiceData(); this._computeIssueClusterCommandServiceData();
} }
private _onManufacturerCodeOverrideChanged(value: ChangeEvent): void { private _onManufacturerCodeOverrideChanged(event): void {
this._manufacturerCodeOverride = value.detail!.value; this._manufacturerCodeOverride = Number(event.target.value);
this._issueClusterCommandServiceData = this._issueClusterCommandServiceData =
this._computeIssueClusterCommandServiceData(); this._computeIssueClusterCommandServiceData();
} }
@ -199,7 +199,8 @@ export class ZHAClusterCommands extends LitElement {
ha-select { ha-select {
margin-top: 16px; margin-top: 16px;
} }
.menu { .menu,
ha-textfield {
width: 100%; width: 100%;
} }

View File

@ -1,4 +1,3 @@
import "@polymer/paper-input/paper-input";
import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
@ -11,6 +10,7 @@ import "../../../../../components/buttons/ha-call-service-button";
import "../../../../../components/entity/state-badge"; import "../../../../../components/entity/state-badge";
import "../../../../../components/ha-area-picker"; import "../../../../../components/ha-area-picker";
import "../../../../../components/ha-card"; import "../../../../../components/ha-card";
import "../../../../../components/ha-textfield";
import { updateDeviceRegistryEntry } from "../../../../../data/device_registry"; import { updateDeviceRegistryEntry } from "../../../../../data/device_registry";
import { import {
EntityRegistryEntry, EntityRegistryEntry,
@ -98,14 +98,14 @@ class ZHADeviceCard extends SubscribeMixin(LitElement) {
: "" : ""
)} )}
</div> </div>
<paper-input <ha-textfield
type="string" type="string"
@change=${this._rename} @change=${this._rename}
.value=${this.device.user_given_name || this.device.name} .value=${this.device.user_given_name || this.device.name}
.label=${this.hass.localize( .label=${this.hass.localize(
"ui.dialogs.zha_device_info.zha_device_card.device_name_placeholder" "ui.dialogs.zha_device_info.zha_device_card.device_name_placeholder"
)} )}
></paper-input> ></ha-textfield>
<ha-area-picker <ha-area-picker
.hass=${this.hass} .hass=${this.hass}
.device=${this.device.device_reg_id} .device=${this.device.device_reg_id}
@ -229,6 +229,9 @@ class ZHADeviceCard extends SubscribeMixin(LitElement) {
ha-card { ha-card {
border: none; border: none;
} }
ha-textfield {
width: 100%;
}
`, `,
]; ];
} }

View File

@ -627,9 +627,6 @@ class HaPanelDevState extends LitElement {
.entities th { .entities th {
padding: 0 8px; padding: 0 8px;
text-align: left; text-align: left;
font-size: var(
--paper-input-container-shared-input-style_-_font-size
);
} }
.filters th { .filters th {

View File

@ -423,9 +423,6 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
th { th {
padding: 0 8px; padding: 0 8px;
text-align: left; text-align: left;
font-size: var(
--paper-input-container-shared-input-style_-_font-size
);
} }
:host([rtl]) th { :host([rtl]) th {

View File

@ -113,11 +113,10 @@ export const haTheme = EditorView.theme({
border: "0", border: "0",
background: "none", background: "none",
fontFamily: "Roboto", fontFamily: "Roboto",
borderBottom: borderBottom: "1px solid var(--secondary-text-color)",
"1px solid var(--paper-input-container-color, var(--secondary-text-color))",
margin: "4px 4px 0", margin: "4px 4px 0",
"& ::placeholder": { "& ::placeholder": {
color: "var(--paper-input-container-color, var(--secondary-text-color))", color: "var(--secondary-text-color)",
}, },
"&:focus": { "&:focus": {
outline: "none", outline: "none",
@ -185,13 +184,11 @@ export const haTheme = EditorView.theme({
"var(--code-editor-gutter-color, var(--secondary-background-color, whitesmoke))", "var(--code-editor-gutter-color, var(--secondary-background-color, whitesmoke))",
color: "var(--paper-dialog-color, var(--secondary-text-color))", color: "var(--paper-dialog-color, var(--secondary-text-color))",
border: "none", border: "none",
borderRight: borderRight: "1px solid var(--secondary-text-color)",
"1px solid var(--paper-input-container-color, var(--secondary-text-color))",
paddingRight: "1px", paddingRight: "1px",
}, },
"&.cm-focused .cm-gutters": { "&.cm-focused .cm-gutters": {
borderRight: borderRight: "2px solid var(--primary-color)",
"2px solid var(--paper-input-container-focus-color, var(--primary-color))",
paddingRight: "0", paddingRight: "0",
}, },
".cm-gutterElement.lineNumber": { color: "inherit" }, ".cm-gutterElement.lineNumber": { color: "inherit" },