import { menu_item_styles_default } from "./chunk.M33MBZ7O.js"; import { SubmenuController } from "./chunk.OHV2QGLG.js"; import { SlPopup } from "./chunk.SJLA5ROP.js"; import { SlSpinner } from "./chunk.TEPHFVM5.js"; import { LocalizeController } from "./chunk.NH3SRVOC.js"; import { HasSlotController, getTextContent } from "./chunk.NYIIDP5N.js"; import { e } from "./chunk.UZVKBFXH.js"; import { SlIcon } from "./chunk.UZYAV5H6.js"; import { watch } from "./chunk.FA5RT4K4.js"; import { ShoelaceElement, e as e2, n } from "./chunk.SEXBCYCU.js"; import { x } from "./chunk.CXZZ2LVK.js"; import { __decorateClass } from "./chunk.KIILAQWQ.js"; // src/components/menu-item/menu-item.component.ts var SlMenuItem = class extends ShoelaceElement { constructor() { super(...arguments); this.type = "normal"; this.checked = false; this.value = ""; this.loading = false; this.disabled = false; this.localize = new LocalizeController(this); this.hasSlotController = new HasSlotController(this, "submenu"); this.submenuController = new SubmenuController(this, this.hasSlotController, this.localize); this.handleHostClick = (event) => { if (this.disabled) { event.preventDefault(); event.stopImmediatePropagation(); } }; this.handleMouseOver = (event) => { this.focus(); event.stopPropagation(); }; } connectedCallback() { super.connectedCallback(); this.addEventListener("click", this.handleHostClick); this.addEventListener("mouseover", this.handleMouseOver); } disconnectedCallback() { super.disconnectedCallback(); this.removeEventListener("click", this.handleHostClick); this.removeEventListener("mouseover", this.handleMouseOver); } handleDefaultSlotChange() { const textLabel = this.getTextLabel(); if (typeof this.cachedTextLabel === "undefined") { this.cachedTextLabel = textLabel; return; } if (textLabel !== this.cachedTextLabel) { this.cachedTextLabel = textLabel; this.emit("slotchange", { bubbles: true, composed: false, cancelable: false }); } } handleCheckedChange() { if (this.checked && this.type !== "checkbox") { this.checked = false; console.error('The checked attribute can only be used on menu items with type="checkbox"', this); return; } if (this.type === "checkbox") { this.setAttribute("aria-checked", this.checked ? "true" : "false"); } else { this.removeAttribute("aria-checked"); } } handleDisabledChange() { this.setAttribute("aria-disabled", this.disabled ? "true" : "false"); } handleTypeChange() { if (this.type === "checkbox") { this.setAttribute("role", "menuitemcheckbox"); this.setAttribute("aria-checked", this.checked ? "true" : "false"); } else { this.setAttribute("role", "menuitem"); this.removeAttribute("aria-checked"); } } /** Returns a text label based on the contents of the menu item's default slot. */ getTextLabel() { return getTextContent(this.defaultSlot); } isSubmenu() { return this.hasSlotController.test("submenu"); } render() { const isRtl = this.localize.dir() === "rtl"; const isSubmenuExpanded = this.submenuController.isExpanded(); return x`