import "@polymer/paper-input/paper-input"; import "@polymer/paper-radio-button/paper-radio-button"; import "@polymer/paper-radio-group/paper-radio-group"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-icon-input"; import { InputText } from "../../../../data/input_text"; import { haStyle } from "../../../../resources/styles"; import { HomeAssistant } from "../../../../types"; @customElement("ha-input_text-form") class HaInputTextForm extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @property() public new?: boolean; private _item?: InputText; @state() private _name!: string; @state() private _icon!: string; @state() private _max?: number; @state() private _min?: number; @state() private _mode?: string; @state() private _pattern?: string; set item(item: InputText) { this._item = item; if (item) { this._name = item.name || ""; this._icon = item.icon || ""; this._max = item.max || 100; this._min = item.min || 0; this._mode = item.mode || "text"; this._pattern = item.pattern; } else { this._name = ""; this._icon = ""; this._max = 100; this._min = 0; this._mode = "text"; } } public focus() { this.updateComplete.then(() => ( this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement )?.focus() ); } protected render(): TemplateResult { if (!this.hass) { return html``; } const nameInvalid = !this._name || this._name.trim() === ""; return html`