1 | import {
|
2 | menu_item_styles_default
|
3 | } from "./chunk.ZMJGXRI5.js";
|
4 | import {
|
5 | getTextContent
|
6 | } from "./chunk.3IYPB6RR.js";
|
7 | import {
|
8 | o
|
9 | } from "./chunk.IAELDRGJ.js";
|
10 | import {
|
11 | watch
|
12 | } from "./chunk.W6MGCO4G.js";
|
13 | import {
|
14 | emit
|
15 | } from "./chunk.UY5AQKHP.js";
|
16 | import {
|
17 | e,
|
18 | i,
|
19 | n
|
20 | } from "./chunk.VKNZYXSO.js";
|
21 | import {
|
22 | $,
|
23 | s
|
24 | } from "./chunk.WWAD5WF4.js";
|
25 | import {
|
26 | __decorateClass
|
27 | } from "./chunk.K2NRSETB.js";
|
28 |
|
29 |
|
30 | var SlMenuItem = class extends s {
|
31 | constructor() {
|
32 | super(...arguments);
|
33 | this.checked = false;
|
34 | this.value = "";
|
35 | this.disabled = false;
|
36 | }
|
37 | firstUpdated() {
|
38 | this.setAttribute("role", "menuitem");
|
39 | }
|
40 | getTextLabel() {
|
41 | return getTextContent(this.defaultSlot);
|
42 | }
|
43 | handleCheckedChange() {
|
44 | this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
45 | }
|
46 | handleDisabledChange() {
|
47 | this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
48 | }
|
49 | handleDefaultSlotChange() {
|
50 | const textLabel = this.getTextLabel();
|
51 | if (typeof this.cachedTextLabel === "undefined") {
|
52 | this.cachedTextLabel = textLabel;
|
53 | return;
|
54 | }
|
55 | if (textLabel !== this.cachedTextLabel) {
|
56 | this.cachedTextLabel = textLabel;
|
57 | emit(this, "sl-label-change");
|
58 | }
|
59 | }
|
60 | render() {
|
61 | return $`
|
62 | <div
|
63 | part="base"
|
64 | class=${o({
|
65 | "menu-item": true,
|
66 | "menu-item--checked": this.checked,
|
67 | "menu-item--disabled": this.disabled,
|
68 | "menu-item--has-submenu": false
|
69 | })}
|
70 | >
|
71 | <span part="checked-icon" class="menu-item__check">
|
72 | <sl-icon name="check-lg" library="system" aria-hidden="true"></sl-icon>
|
73 | </span>
|
74 |
|
75 | <span part="prefix" class="menu-item__prefix">
|
76 | <slot name="prefix"></slot>
|
77 | </span>
|
78 |
|
79 | <span part="label" class="menu-item__label">
|
80 | <slot @slotchange=${this.handleDefaultSlotChange}></slot>
|
81 | </span>
|
82 |
|
83 | <span part="suffix" class="menu-item__suffix">
|
84 | <slot name="suffix"></slot>
|
85 | </span>
|
86 |
|
87 | <span class="menu-item__chevron">
|
88 | <sl-icon name="chevron-right" library="system" aria-hidden="true"></sl-icon>
|
89 | </span>
|
90 | </div>
|
91 | `;
|
92 | }
|
93 | };
|
94 | SlMenuItem.styles = menu_item_styles_default;
|
95 | __decorateClass([
|
96 | i("slot:not([name])")
|
97 | ], SlMenuItem.prototype, "defaultSlot", 2);
|
98 | __decorateClass([
|
99 | i(".menu-item")
|
100 | ], SlMenuItem.prototype, "menuItem", 2);
|
101 | __decorateClass([
|
102 | e({ type: Boolean, reflect: true })
|
103 | ], SlMenuItem.prototype, "checked", 2);
|
104 | __decorateClass([
|
105 | e()
|
106 | ], SlMenuItem.prototype, "value", 2);
|
107 | __decorateClass([
|
108 | e({ type: Boolean, reflect: true })
|
109 | ], SlMenuItem.prototype, "disabled", 2);
|
110 | __decorateClass([
|
111 | watch("checked")
|
112 | ], SlMenuItem.prototype, "handleCheckedChange", 1);
|
113 | __decorateClass([
|
114 | watch("disabled")
|
115 | ], SlMenuItem.prototype, "handleDisabledChange", 1);
|
116 | SlMenuItem = __decorateClass([
|
117 | n("sl-menu-item")
|
118 | ], SlMenuItem);
|
119 |
|
120 | export {
|
121 | SlMenuItem
|
122 | };
|