/** Reusable confirmation dialog wrapping . */ import { LitElement, html, css, nothing } from "lit"; import { property, state } from "lit/decorators.js"; import type { HomeAssistant } from "../types"; import { langOf, t, nativeFieldStyles } from "../styles"; export interface ConfirmOptions { title: string; message: string; confirmText?: string; danger?: boolean; } export interface PromptOptions extends ConfirmOptions { inputLabel?: string; inputType?: string; // "text" | "date" etc. inputValue?: string; /** Render a (this._inputValue = (e.target as HTMLSelectElement).value)}> ${this._options.map((o) => html``)} ` : html` (this._inputValue = (e.target as HTMLInputElement).value)} />`} ` : nothing}
${t("cancel", lang)} ${this._confirmText}
`; } static styles = [nativeFieldStyles, css` .dialog-title { font-size: 18px; font-weight: 500; padding-bottom: 12px; } /* shared native-field scaffold from nativeFieldStyles; the prompt input follows the message text, hence the extra top margin here */ .field { margin-top: 12px; } .content { padding: 8px 0; min-width: 280px; line-height: 1.5; display: flex; flex-direction: column; gap: 12px; } .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; } ha-textfield { display: block; } ha-button.danger { --mdc-theme-primary: var(--error-color, #f44336); } `]; } if (!customElements.get("maintenance-confirm-dialog")) { customElements.define("maintenance-confirm-dialog", MaintenanceConfirmDialog); }