import { mdiDotsVertical } from "@mdi/js"; import type { TemplateResult } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { haStyle } from "../resources/styles"; import type { HomeAssistant } from "../types"; import "./ha-md-button-menu"; import "./ha-icon-button"; import "./ha-svg-icon"; import "./ha-tooltip"; import "./ha-md-menu-item"; import "./ha-md-divider"; export interface IconOverflowMenuItem { [key: string]: any; path: string; label: string; narrowOnly?: boolean; disabled?: boolean; tooltip?: string; action: () => any; warning?: boolean; divider?: boolean; } @customElement("ha-icon-overflow-menu") export class HaIconOverflowMenu extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @property({ type: Array }) public items: IconOverflowMenuItem[] = []; @property({ type: Boolean }) public narrow = false; protected render(): TemplateResult { return html` ${this.narrow ? html` ${this.items.map((item) => item.divider ? html`` : html` ${item.label} ` )} ` : html` ${this.items.map((item) => item.narrowOnly ? nothing : item.divider ? html`
` : html`${item.tooltip ?? ""} ` )} `} `; } protected _handleIconOverflowMenuOpened(e) { e.stopPropagation(); } static get styles() { return [ haStyle, css` :host { display: flex; justify-content: flex-end; } div[role="separator"] { border-right: 1px solid var(--divider-color); width: 1px; } `, ]; } } declare global { interface HTMLElementTagNameMap { "ha-icon-overflow-menu": HaIconOverflowMenu; } }