mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-06 09:29:40 +00:00
Convert icon picker to ha-combobox (#11586)
Co-authored-by: Zack <zackbarett@hey.com>
This commit is contained in:
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user