import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; 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 { InputDateTime } from "../../../../data/input_datetime"; import { haStyle } from "../../../../resources/styles"; import { HomeAssistant } from "../../../../types"; @customElement("ha-input_datetime-form") class HaInputDateTimeForm extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @property() public new?: boolean; private _item?: InputDateTime; @state() private _name!: string; @state() private _icon!: string; @state() private _mode!: "date" | "time" | "datetime"; set item(item: InputDateTime) { this._item = item; if (item) { this._name = item.name || ""; this._icon = item.icon || ""; this._mode = item.has_time && item.has_date ? "datetime" : item.has_time ? "time" : "date"; this._item.has_date = !item.has_date && !item.has_time ? true : item.has_date; } else { this._name = ""; this._icon = ""; this._mode = "date"; } } public focus() { this.updateComplete.then(() => ( this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement )?.focus() ); } protected render() { if (!this.hass) { return nothing; } return html`