Convert icon picker to ha-combobox (#11586)

Co-authored-by: Zack <zackbarett@hey.com>
This commit is contained in:
Bram Kragten
2022-02-07 17:43:49 +01:00
committed by GitHub
parent 869fa91ae5
commit 2cb37820df
3 changed files with 84 additions and 83 deletions

View File

@@ -1,10 +1,31 @@
import { TextField } from "@material/mwc-textfield";
import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators";
import { TemplateResult, html, PropertyValues } from "lit";
import { customElement, property } from "lit/decorators";
@customElement("ha-textfield")
export class HaTextField extends TextField {
override renderIcon(_icon: string, isTrailingIcon = false): TemplateResult {
@property({ type: Boolean }) public invalid?: boolean;
@property({ attribute: "error-message" }) public errorMessage?: string;
override updated(changedProperties: PropertyValues) {
super.updated(changedProperties);
if (
(changedProperties.has("invalid") &&
(this.invalid || changedProperties.get("invalid") !== undefined)) ||
changedProperties.has("errorMessage")
) {
this.setCustomValidity(
this.invalid ? this.errorMessage || "Invalid" : ""
);
this.reportValidity();
}
}
protected override renderIcon(
_icon: string,
isTrailingIcon = false
): TemplateResult {
const type = isTrailingIcon ? "trailing" : "leading";
return html`