@m3e/nav-menu 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,884 @@
1
+ /**
2
+ * @license MIT
3
+ * Copyright (c) 2025 matraic
4
+ * See LICENSE file in the project root for full license text.
5
+ */
6
+ import { LitElement, html, css, unsafeCSS } from 'lit';
7
+ import { Role, PressedController, FocusController, DesignToken, scrollIntoViewIfNeeded, Selected, Disabled, EventAttribute, AttachInternals, hasAssignedNodes } from '@m3e/core';
8
+ import { SelectionManager, selectionManager } from '@m3e/core/a11y';
9
+
10
+ /******************************************************************************
11
+ Copyright (c) Microsoft Corporation.
12
+
13
+ Permission to use, copy, modify, and/or distribute this software for any
14
+ purpose with or without fee is hereby granted.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
+ PERFORMANCE OF THIS SOFTWARE.
23
+ ***************************************************************************** */
24
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
+
26
+
27
+ function __decorate(decorators, target, key, desc) {
28
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ }
33
+
34
+ function __classPrivateFieldGet(receiver, state, kind, f) {
35
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
36
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
37
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
+ }
39
+
40
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
41
+ if (kind === "m") throw new TypeError("Private method is not writable");
42
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
43
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
44
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
45
+ }
46
+
47
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48
+ var e = new Error(message);
49
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
50
+ };
51
+
52
+ /**
53
+ * @license
54
+ * Copyright 2017 Google LLC
55
+ * SPDX-License-Identifier: BSD-3-Clause
56
+ */
57
+ const t$2=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
58
+
59
+ /**
60
+ * @license
61
+ * Copyright 2019 Google LLC
62
+ * SPDX-License-Identifier: BSD-3-Clause
63
+ */
64
+ const t$1=globalThis,e$4=t$1.ShadowRoot&&(void 0===t$1.ShadyCSS||t$1.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$4=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$1)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$4&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$4.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$4.set(s,t));}return t}toString(){return this.cssText}};const r$4=t=>new n$3("string"==typeof t?t:t+"",void 0,s$1),S$1=(s,o)=>{if(e$4)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$1.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$4?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$4(e)})(t):t;
65
+
66
+ /**
67
+ * @license
68
+ * Copyright 2017 Google LLC
69
+ * SPDX-License-Identifier: BSD-3-Clause
70
+ */const{is:i$1,defineProperty:e$3,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,getOwnPropertySymbols:o$3,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$1(t,s),b={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$3(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$3(t),...o$3(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d$1("elementProperties")]=new Map,y[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
71
+
72
+ /**
73
+ * @license
74
+ * Copyright 2017 Google LLC
75
+ * SPDX-License-Identifier: BSD-3-Clause
76
+ */const o$2={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$2=(t=o$2,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n$1(t){return (e,o)=>"object"==typeof o?r$2(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
77
+
78
+ /**
79
+ * @license
80
+ * Copyright 2017 Google LLC
81
+ * SPDX-License-Identifier: BSD-3-Clause
82
+ */function r$1(r){return n$1({...r,state:true,attribute:false})}
83
+
84
+ /**
85
+ * @license
86
+ * Copyright 2017 Google LLC
87
+ * SPDX-License-Identifier: BSD-3-Clause
88
+ */
89
+ const e$2=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
90
+
91
+ /**
92
+ * @license
93
+ * Copyright 2017 Google LLC
94
+ * SPDX-License-Identifier: BSD-3-Clause
95
+ */function e$1(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$2(n,s,{get(){return o(this)}})}}
96
+
97
+ var _M3eNavMenuElement_instances, _M3eNavMenuElement_ignoreFocusVisible, _M3eNavMenuElement_ignoreFocus, _M3eNavMenuElement_keyDownHandler, _M3eNavMenuElement_keyUpHandler, _M3eNavMenuElement_pointerDownHandler, _M3eNavMenuElement_handleSlotChange, _M3eNavMenuElement_handleKeyDown, _M3eNavMenuElement_handleKeyUp, _M3eNavMenuElement_handlePointerDown, _M3eNavMenuElement_activateItem, _M3eNavMenuElement_updateFocusVisible, _M3eNavMenuElement_updateItemFocusVisible, _b;
98
+ var M3eNavMenuElement_1;
99
+ /**
100
+ * @summary
101
+ * Presents a hierarchical menu.
102
+ *
103
+ * @description
104
+ * The `m3e-nav-menu` component provides a hierarchical, accessible navigation menu supporting
105
+ * nested expandable items, keyboard navigation, and focus management. It is highly customizable
106
+ * via slots and CSS custom properties, and is designed for use in sidebars, navigation drawers,
107
+ * and complex menu structures.
108
+ *
109
+ * @example
110
+ * The following example illustrates a multilevel navigation menu.
111
+ * ```html
112
+ * <m3e-nav-menu>
113
+ * <m3e-nav-menu-item open>
114
+ * <m3e-icon slot="icon" name="rocket_launch"></m3e-icon>
115
+ * <span slot="label">Getting Started</span>
116
+ * <m3e-nav-menu-item>
117
+ * <m3e-icon slot="icon" name="widgets"></m3e-icon>
118
+ * <span slot="label">Overview</span>
119
+ * </m3e-nav-menu-item>
120
+ * <m3e-nav-menu-item>
121
+ * <m3e-icon slot="icon" name="package_2"></m3e-icon>
122
+ * <span slot="label">Installation</span>
123
+ * </m3e-nav-menu-item>
124
+ * </m3e-nav-menu-item>
125
+ * <m3e-nav-menu-item>
126
+ * <span slot="label">Actions</span>
127
+ * <m3e-nav-menu-item><span slot="label">Button</span></m3e-nav-menu-item>
128
+ * <m3e-nav-menu-item><span slot="label">Icon</span></m3e-nav-menu-item>
129
+ * <m3e-nav-menu-item><span slot="label">Icon Button</span></m3e-nav-menu-item>
130
+ * </m3e-nav-menu-item>
131
+ * </m3e-nav-menu>
132
+ * ```
133
+ *
134
+ * @tag m3e-nav-menu
135
+ *
136
+ * @slot - Renders the items of the menu.
137
+ *
138
+ * @cssprop --m3e-nav-menu-padding-top - Top padding for the menu.
139
+ * @cssprop --m3e-nav-menu-padding-bottom - Bottom padding for the menu.
140
+ * @cssprop --m3e-nav-menu-padding-left - Left padding for the menu.
141
+ * @cssprop --m3e-nav-menu-padding-right - Right padding for the menu.
142
+ * @cssprop --m3e-nav-menu-divider-margin - Margin for divider elements in the menu.
143
+ * @cssprop --m3e-nav-menu-scrollbar-width - Width of the menu scrollbar.
144
+ * @cssprop --m3e-nav-menu-scrollbar-color - Color of the menu scrollbar.
145
+ */
146
+ let M3eNavMenuElement = M3eNavMenuElement_1 = class M3eNavMenuElement extends Role(LitElement, "tree") {
147
+ constructor() {
148
+ super();
149
+ _M3eNavMenuElement_instances.add(this);
150
+ /** @private */ _M3eNavMenuElement_ignoreFocusVisible.set(this, false);
151
+ /** @private */ _M3eNavMenuElement_ignoreFocus.set(this, false);
152
+ /** @private */
153
+ this[_b] = new SelectionManager()
154
+ .withVerticalOrientation()
155
+ .withHomeAndEnd()
156
+ .withTypeahead()
157
+ .withSkipPredicate((x) => x.disabled || !x.visible)
158
+ .disableRovingTabIndex()
159
+ .onActiveItemChange(() => {
160
+ if (this[selectionManager].activeItem) {
161
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_activateItem).call(this, this[selectionManager].activeItem);
162
+ }
163
+ })
164
+ .onSelectedItemsChange(() => {
165
+ const selected = this.selected;
166
+ for (const item of this.items) {
167
+ if (item !== selected) {
168
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateItemFocusVisible).call(this, item, false, false);
169
+ }
170
+ }
171
+ });
172
+ /** @private */ _M3eNavMenuElement_keyDownHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_handleKeyDown).call(this, e));
173
+ /** @private */ _M3eNavMenuElement_keyUpHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_handleKeyUp).call(this, e));
174
+ /** @private */ _M3eNavMenuElement_pointerDownHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_handlePointerDown).call(this, e));
175
+ new PressedController(this, { callback: (pressed) => (__classPrivateFieldSet(this, _M3eNavMenuElement_ignoreFocus, pressed, "f")) });
176
+ new FocusController(this, {
177
+ callback: () => {
178
+ if (!__classPrivateFieldGet(this, _M3eNavMenuElement_ignoreFocus, "f")) {
179
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateFocusVisible).call(this);
180
+ }
181
+ },
182
+ });
183
+ }
184
+ /** The selected item of the menu. */
185
+ get selected() {
186
+ return this[selectionManager].selectedItems[0] ?? null;
187
+ }
188
+ /** All the items of the menu. */
189
+ get items() {
190
+ return this[selectionManager].items;
191
+ }
192
+ /**
193
+ * Expands the specified items, or all items if no items are provided.
194
+ * @param {M3eNavMenuItemElement | undefined} items The items to expand.
195
+ */
196
+ expand(items) {
197
+ (items ?? this[selectionManager].items).forEach((x) => x.expand());
198
+ }
199
+ /**
200
+ * Collapses the specified items, or all items if no items are provided.
201
+ * @param {M3eNavMenuItemElement | undefined} items The items to collapse.
202
+ */
203
+ collapse(items) {
204
+ (items ?? this[selectionManager].items).forEach((x) => x.collapse());
205
+ const activeItem = this[selectionManager].activeItem;
206
+ if (activeItem && !activeItem.visible) {
207
+ for (let parent = activeItem.parentItem; parent; parent = parent.parentItem) {
208
+ if (parent.visible) {
209
+ this[selectionManager].setActiveItem(parent);
210
+ break;
211
+ }
212
+ }
213
+ }
214
+ }
215
+ /** @inheritdoc */
216
+ connectedCallback() {
217
+ super.connectedCallback();
218
+ this.setAttribute("tabindex", "0");
219
+ this.addEventListener("keydown", __classPrivateFieldGet(this, _M3eNavMenuElement_keyDownHandler, "f"));
220
+ this.addEventListener("keyup", __classPrivateFieldGet(this, _M3eNavMenuElement_keyUpHandler, "f"));
221
+ this.addEventListener("pointerdown", __classPrivateFieldGet(this, _M3eNavMenuElement_pointerDownHandler, "f"));
222
+ }
223
+ /** @inheritdoc */
224
+ disconnectedCallback() {
225
+ super.disconnectedCallback();
226
+ this.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eNavMenuElement_keyDownHandler, "f"));
227
+ this.removeEventListener("keyup", __classPrivateFieldGet(this, _M3eNavMenuElement_keyUpHandler, "f"));
228
+ this.removeEventListener("pointerdown", __classPrivateFieldGet(this, _M3eNavMenuElement_pointerDownHandler, "f"));
229
+ }
230
+ /** @inheritdoc */
231
+ render() {
232
+ return html `<slot @slotchange="${__classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_handleSlotChange)}"></slot>`;
233
+ }
234
+ };
235
+ _M3eNavMenuElement_ignoreFocusVisible = new WeakMap();
236
+ _M3eNavMenuElement_ignoreFocus = new WeakMap();
237
+ _M3eNavMenuElement_keyDownHandler = new WeakMap();
238
+ _M3eNavMenuElement_keyUpHandler = new WeakMap();
239
+ _M3eNavMenuElement_pointerDownHandler = new WeakMap();
240
+ _M3eNavMenuElement_instances = new WeakSet();
241
+ _b = selectionManager;
242
+ _M3eNavMenuElement_handleSlotChange = function _M3eNavMenuElement_handleSlotChange() {
243
+ const { added } = this[selectionManager].setItems([...this.querySelectorAll("m3e-nav-menu-item")]);
244
+ for (const item of added) {
245
+ item.id = item.id || `m3e-nav-menu-item-${M3eNavMenuElement_1.__nextId++}`;
246
+ }
247
+ if (this[selectionManager].activeItem) {
248
+ this.setAttribute("aria-activedescendant", this[selectionManager].activeItem.id);
249
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateFocusVisible).call(this);
250
+ }
251
+ else {
252
+ this.removeAttribute("aria-activedescendant");
253
+ }
254
+ };
255
+ _M3eNavMenuElement_handleKeyDown = function _M3eNavMenuElement_handleKeyDown(e) {
256
+ __classPrivateFieldSet(this, _M3eNavMenuElement_ignoreFocusVisible, false, "f");
257
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateFocusVisible).call(this);
258
+ const item = this[selectionManager].activeItem;
259
+ if (e.defaultPrevented || !item || item.disabled)
260
+ return;
261
+ switch (e.key) {
262
+ case "Enter":
263
+ case " ":
264
+ e.preventDefault();
265
+ if (item.ripple && !item.ripple.visible) {
266
+ item.ripple.show(0, 0, true);
267
+ }
268
+ if (item.hasChildItems) {
269
+ item.toggle();
270
+ }
271
+ else if (!item.selected) {
272
+ this[selectionManager].select(item);
273
+ item.link?.click();
274
+ }
275
+ break;
276
+ case "*":
277
+ e.preventDefault();
278
+ item.expand(true);
279
+ break;
280
+ case "Left":
281
+ case "ArrowLeft":
282
+ e.preventDefault();
283
+ if (item.hasChildItems && item.open) {
284
+ item.collapse();
285
+ }
286
+ else {
287
+ const parent = item.parentItem;
288
+ if (parent) {
289
+ parent.collapse();
290
+ this[selectionManager].setActiveItem(parent);
291
+ }
292
+ }
293
+ break;
294
+ case "Right":
295
+ case "ArrowRight":
296
+ if (item.hasChildItems) {
297
+ if (!item.open) {
298
+ e.preventDefault();
299
+ item.expand();
300
+ }
301
+ else {
302
+ try {
303
+ this[selectionManager].vertical = false;
304
+ this[selectionManager].onKeyDown(e);
305
+ }
306
+ finally {
307
+ this[selectionManager].vertical = true;
308
+ }
309
+ }
310
+ }
311
+ else {
312
+ e.preventDefault();
313
+ }
314
+ break;
315
+ default:
316
+ this[selectionManager].onKeyDown(e);
317
+ break;
318
+ }
319
+ };
320
+ _M3eNavMenuElement_handleKeyUp = function _M3eNavMenuElement_handleKeyUp(e) {
321
+ const item = this[selectionManager].activeItem;
322
+ if (e.defaultPrevented || !item || item.disabled)
323
+ return;
324
+ switch (e.key) {
325
+ case "Enter":
326
+ case " ":
327
+ item.ripple?.hide();
328
+ break;
329
+ }
330
+ };
331
+ _M3eNavMenuElement_handlePointerDown = function _M3eNavMenuElement_handlePointerDown(e) {
332
+ if (!e.defaultPrevented && !__classPrivateFieldGet(this, _M3eNavMenuElement_ignoreFocusVisible, "f")) {
333
+ __classPrivateFieldSet(this, _M3eNavMenuElement_ignoreFocusVisible, true, "f");
334
+ if (this[selectionManager].activeItem) {
335
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateItemFocusVisible).call(this, this[selectionManager].activeItem, true, false);
336
+ }
337
+ }
338
+ };
339
+ _M3eNavMenuElement_activateItem = function _M3eNavMenuElement_activateItem(item) {
340
+ this.setAttribute("aria-activedescendant", item.id);
341
+ scrollIntoViewIfNeeded(item, this, "instant");
342
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateFocusVisible).call(this);
343
+ };
344
+ _M3eNavMenuElement_updateFocusVisible = function _M3eNavMenuElement_updateFocusVisible() {
345
+ const focused = this.matches(":focus") || this.matches(":focus-within");
346
+ const focusVisible = !__classPrivateFieldGet(this, _M3eNavMenuElement_ignoreFocusVisible, "f") && this.matches(":focus-visible");
347
+ this[selectionManager].items.forEach((x) => {
348
+ const active = x === this[selectionManager].activeItem;
349
+ __classPrivateFieldGet(this, _M3eNavMenuElement_instances, "m", _M3eNavMenuElement_updateItemFocusVisible).call(this, x, active && focused, active && focusVisible);
350
+ });
351
+ };
352
+ _M3eNavMenuElement_updateItemFocusVisible = function _M3eNavMenuElement_updateItemFocusVisible(item, focused, focusVisible) {
353
+ if (focused) {
354
+ item.stateLayer?.show("focused");
355
+ }
356
+ else {
357
+ item.stateLayer?.hide("focused");
358
+ }
359
+ if (focusVisible) {
360
+ item.focusRing?.show();
361
+ }
362
+ else {
363
+ item.focusRing?.hide();
364
+ }
365
+ };
366
+ /** The styles of the element. */
367
+ M3eNavMenuElement.styles = css `
368
+ :host {
369
+ display: flex;
370
+ flex-direction: column;
371
+ outline: none;
372
+ overflow-y: auto;
373
+ overflow-x: hidden;
374
+ position: relative;
375
+ min-height: 0;
376
+ padding-block-start: var(--m3e-nav-menu-padding-top, 0.5rem);
377
+ padding-block-end: var(--m3e-nav-menu-padding-bottom, 0.5rem);
378
+ padding-inline-start: var(--m3e-nav-menu-padding-left, 0.75rem);
379
+ padding-inline-end: var(--m3e-nav-menu-padding-right, 0.75rem);
380
+ scrollbar-width: ${DesignToken.scrollbar.width};
381
+ scrollbar-color: ${DesignToken.scrollbar.color};
382
+ }
383
+ ::slotted(m3e-divider) {
384
+ margin-block: var(--m3e-nav-menu-divider-margin, 0.25rem);
385
+ }
386
+ `;
387
+ /** @private */ M3eNavMenuElement.__nextId = 0;
388
+ M3eNavMenuElement = M3eNavMenuElement_1 = __decorate([
389
+ t$2("m3e-nav-menu")
390
+ ], M3eNavMenuElement);
391
+
392
+ /**
393
+ * @license
394
+ * Copyright 2017 Google LLC
395
+ * SPDX-License-Identifier: BSD-3-Clause
396
+ */
397
+ const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$1="?"+h,n=`<${o$1}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$1)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");
398
+
399
+ /**
400
+ * @license
401
+ * Copyright 2018 Google LLC
402
+ * SPDX-License-Identifier: BSD-3-Clause
403
+ */const o=o=>o??E;
404
+
405
+ var _M3eNavMenuItemElement_instances, _M3eNavMenuItemElement_items, _M3eNavMenuItemElement_menu, _M3eNavMenuItemElement_path, _M3eNavMenuItemElement_link, _M3eNavMenuItemElement_renderIcon, _M3eNavMenuItemElement_handleIconSlotChange, _M3eNavMenuItemElement_handleSlotChange, _M3eNavMenuItemElement_handleItemSlotChange, _M3eNavMenuItemElement_handleClick, _M3eNavMenuItemElement_handleCollapsibleEvent;
406
+ var M3eNavMenuItemElement_1;
407
+ /**
408
+ * @summary
409
+ * An expandable item in a navigation menu.
410
+ *
411
+ * @description
412
+ * The `m3e-nav-menu-item` component represents an expandable, selectable item within a navigation menu.
413
+ * It supports nested child items, selection, disabled and indeterminate states, and emits events for
414
+ * open/close transitions. The component is highly customizable via slots and CSS custom properties, and
415
+ * is designed for accessible, keyboard-navigable menu structures.
416
+ *
417
+ * @example
418
+ * The following example illustrates a multilevel navigation menu.
419
+ * ```html
420
+ * <m3e-nav-menu>
421
+ * <m3e-nav-menu-item open>
422
+ * <m3e-icon slot="icon" name="rocket_launch"></m3e-icon>
423
+ * <span slot="label">Getting Started</span>
424
+ * <m3e-nav-menu-item>
425
+ * <m3e-icon slot="icon" name="widgets"></m3e-icon>
426
+ * <span slot="label">Overview</span>
427
+ * </m3e-nav-menu-item>
428
+ * <m3e-nav-menu-item>
429
+ * <m3e-icon slot="icon" name="package_2"></m3e-icon>
430
+ * <span slot="label">Installation</span>
431
+ * </m3e-nav-menu-item>
432
+ * </m3e-nav-menu-item>
433
+ * <m3e-nav-menu-item>
434
+ * <span slot="label">Actions</span>
435
+ * <m3e-nav-menu-item><span slot="label">Button</span></m3e-nav-menu-item>
436
+ * <m3e-nav-menu-item><span slot="label">Icon</span></m3e-nav-menu-item>
437
+ * <m3e-nav-menu-item><span slot="label">Icon Button</span></m3e-nav-menu-item>
438
+ * </m3e-nav-menu-item>
439
+ * </m3e-nav-menu>
440
+ * ```
441
+ *
442
+ * @tag m3e-nav-menu-item
443
+ *
444
+ * @slot - Renders the nested child items.
445
+ * @slot label - Renders the label of the item.
446
+ * @slot icon - Renders the icon of the item.
447
+ * @slot selected-icon - Renders the icon of the item when selected.
448
+ * @slot toggle-icon - Renders the toggle icon.
449
+ *
450
+ * @attr disabled - Whether the element is disabled.
451
+ * @attr indeterminate - Whether the element's selected / checked state is indeterminate.
452
+ * @attr open - Whether the item is expanded.
453
+ * @attr selected - Whether the item is selected.
454
+ *
455
+ * @fires opening - Emitted when the item begins to open.
456
+ * @fires opened - Emitted when the item has opened.
457
+ * @fires closing - Emitted when the item begins to close.
458
+ * @fires closed - Emitted when the item has closed.
459
+ *
460
+ * @cssprop --m3e-nav-menu-item-font-size - Font size for the item label.
461
+ * @cssprop --m3e-nav-menu-item-font-weight - Font weight for the item label.
462
+ * @cssprop --m3e-nav-menu-item-line-height - Line height for the item label.
463
+ * @cssprop --m3e-nav-menu-item-tracking - Letter spacing for the item label.
464
+ * @cssprop --m3e-nav-menu-item-padding - Inline padding for the item.
465
+ * @cssprop --m3e-nav-menu-item-height - Height of the item.
466
+ * @cssprop --m3e-nav-menu-item-spacing - Spacing between icon and label.
467
+ * @cssprop --m3e-nav-menu-item-shape - Border radius of the item and focus ring.
468
+ * @cssprop --m3e-nav-menu-item-icon-size - Size of the icon.
469
+ * @cssprop --m3e-nav-menu-item-inset - Indentation for nested items.
470
+ * @cssprop --m3e-nav-menu-item-label-color - Text color for the item label.
471
+ * @cssprop --m3e-nav-menu-item-selected-label-color - Text color for selected item label.
472
+ * @cssprop --m3e-nav-menu-item-selected-container-color - Background color for selected item.
473
+ * @cssprop --m3e-nav-menu-item-selected-container-focus-color - Focus color for selected item container.
474
+ * @cssprop --m3e-nav-menu-item-selected-container-hover-color - Hover color for selected item container.
475
+ * @cssprop --m3e-nav-menu-item-selected-ripple-color - Ripple color for selected item.
476
+ * @cssprop --m3e-nav-menu-item-unselected-container-focus-color - Focus color for unselected item container.
477
+ * @cssprop --m3e-nav-menu-item-unselected-container-hover-color - Hover color for unselected item container.
478
+ * @cssprop --m3e-nav-menu-item-unselected-ripple-color - Ripple color for unselected item.
479
+ * @cssprop --m3e-nav-menu-item-open-container-color - Background color for open item with children.
480
+ * @cssprop --m3e-nav-menu-item-open-container-focus-color - Focus color for open item container.
481
+ * @cssprop --m3e-nav-menu-item-open-container-hover-color - Hover color for open item container.
482
+ * @cssprop --m3e-nav-menu-item-open-ripple-color - Ripple color for open item.
483
+ * @cssprop --m3e-nav-menu-item-disabled-color - Text color for disabled item.
484
+ * @cssprop --m3e-nav-menu-item-disabled-color-opacity - Opacity for disabled item text color.
485
+ * @cssprop --m3e-nav-menu-item-badge-font-size - Font size for badge slot.
486
+ * @cssprop --m3e-nav-menu-item-badge-font-weight - Font weight for badge slot.
487
+ * @cssprop --m3e-nav-menu-item-badge-line-height - Line height for badge slot.
488
+ * @cssprop --m3e-nav-menu-badge-item-tracking - Letter spacing for badge slot.
489
+ * @cssprop --m3e-nav-menu-divider-margin - Margin for divider elements.
490
+ * @cssprop --m3e-nav-menu-item-vertical-inset - Vertical margin for first/last child items.
491
+ */
492
+ let M3eNavMenuItemElement = M3eNavMenuItemElement_1 = class M3eNavMenuItemElement extends Selected(Disabled(EventAttribute(AttachInternals(Role(LitElement, "treeitem"), true), "opening", "opened", "closing", "closed"))) {
493
+ constructor() {
494
+ super(...arguments);
495
+ _M3eNavMenuItemElement_instances.add(this);
496
+ /** @private */ this._hasChildItems = false;
497
+ /** @private */ _M3eNavMenuItemElement_items.set(this, []);
498
+ /** @private */ _M3eNavMenuItemElement_menu.set(this, null);
499
+ /** @private */ _M3eNavMenuItemElement_path.set(this, new Array());
500
+ /** @private */ _M3eNavMenuItemElement_link.set(this, null);
501
+ /**
502
+ * Whether the item is expanded.
503
+ * @default false
504
+ */
505
+ this.open = false;
506
+ }
507
+ /** A reference to the nested `HTMLAnchorElement`. */
508
+ get link() {
509
+ return __classPrivateFieldGet(this, _M3eNavMenuItemElement_link, "f");
510
+ }
511
+ /** Whether the item is visible. */
512
+ get visible() {
513
+ return !__classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").some((x) => !x.open);
514
+ }
515
+ /** The full path of the item, starting with the top-most ancestor, including this item. */
516
+ get path() {
517
+ return [...__classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f"), this];
518
+ }
519
+ /** Whether the item has child items. */
520
+ get hasChildItems() {
521
+ return this._hasChildItems;
522
+ }
523
+ /** The parenting item. */
524
+ get parentItem() {
525
+ return __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f")[__classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").length - 1] ?? null;
526
+ }
527
+ /** The items that immediately descend from this item. */
528
+ get childItems() {
529
+ return __classPrivateFieldGet(this, _M3eNavMenuItemElement_items, "f");
530
+ }
531
+ /** The one-based level of the item. */
532
+ get level() {
533
+ return __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").length + 1;
534
+ }
535
+ /**
536
+ * Expands this item, and optionally, all descendants.
537
+ * @param {boolean} [descendants=false] Whether to expand all descendants.
538
+ */
539
+ expand(descendants = false) {
540
+ if (this.hasChildItems) {
541
+ this.open = true;
542
+ if (descendants) {
543
+ this.childItems.forEach((x) => x.expand(true));
544
+ }
545
+ }
546
+ }
547
+ /**
548
+ * Collapses this item, and optionally, all descendants.
549
+ * @param {boolean} [descendants=false] Whether to expand all descendants.
550
+ */
551
+ collapse(descendants = false) {
552
+ if (this.hasChildItems) {
553
+ this.open = false;
554
+ if (descendants) {
555
+ this.childItems.forEach((x) => x.collapse(true));
556
+ }
557
+ }
558
+ }
559
+ /** Toggles the expanded state of the item. */
560
+ toggle() {
561
+ if (this.hasChildItems) {
562
+ this.open = !this.open;
563
+ }
564
+ }
565
+ /** @inheritdoc */
566
+ connectedCallback() {
567
+ super.connectedCallback();
568
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").length = 0;
569
+ for (let item = this.parentElement?.closest("m3e-nav-menu-item"); item; item = item.parentElement?.closest("m3e-nav-menu-item")) {
570
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").push(item);
571
+ }
572
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").reverse();
573
+ this.style.setProperty("--_nav-menu-item-level", `${this.level}`);
574
+ __classPrivateFieldSet(this, _M3eNavMenuItemElement_menu, this.closest("m3e-nav-menu"), "f");
575
+ }
576
+ /** @inheritdoc */
577
+ disconnectedCallback() {
578
+ super.disconnectedCallback();
579
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").length = 0;
580
+ }
581
+ /** @inheritdoc */
582
+ update(changedProperties) {
583
+ super.update(changedProperties);
584
+ if (changedProperties.has("selected")) {
585
+ this.ariaCurrent = this.hasChildItems ? null : `${this.selected}`;
586
+ for (const icon of this.querySelectorAll(":scope > m3e-icon[slot]")) {
587
+ icon.toggleAttribute("filled", this.selected);
588
+ }
589
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").forEach((x) => (x.selected = this.selected));
590
+ if (this.selected && !this.hasChildItems) {
591
+ this.closest("m3e-nav-menu")?.[selectionManager].notifySelectionChange(this);
592
+ }
593
+ }
594
+ }
595
+ /** @inheritdoc */
596
+ firstUpdated(_changedProperties) {
597
+ super.firstUpdated(_changedProperties);
598
+ const base = this._base;
599
+ if (base) {
600
+ [this.focusRing, this.stateLayer, this.ripple].forEach((x) => x?.attach(base));
601
+ }
602
+ }
603
+ /** @inheritdoc */
604
+ render() {
605
+ return html `<div class="base" @click="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleClick)}">
606
+ <m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
607
+ <m3e-focus-ring class="focus-ring" inward ?disabled="${this.disabled}"></m3e-focus-ring>
608
+ <m3e-ripple class="ripple" centered ?disabled="${this.disabled}"></m3e-ripple>
609
+ <div class="icon">${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_renderIcon).call(this)}</div>
610
+ <div class="label">
611
+ <slot name="label" @slotchange="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleSlotChange)}"></slot>
612
+ </div>
613
+ <slot name="badge"></slot>
614
+ <div aria-hidden="true" class="toggle">
615
+ <slot name="toggle-icon">
616
+ <svg class="toggle-icon" viewBox="0 -960 960 960" fill="currentColor">
617
+ <path d="M480-360 280-560h400L480-360Z" />
618
+ </svg>
619
+ </slot>
620
+ </div>
621
+ </div>
622
+ <m3e-collapsible
623
+ class="group"
624
+ role="group"
625
+ aria-hidden="${o(this._hasChildItems ? undefined : "true")}"
626
+ ?open="${this._hasChildItems && this.open}"
627
+ @opening="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleCollapsibleEvent)}"
628
+ @opened="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleCollapsibleEvent)}"
629
+ @closing="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleCollapsibleEvent)}"
630
+ @closed="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleCollapsibleEvent)}"
631
+ >
632
+ <slot @slotchange="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleItemSlotChange)}"></slot>
633
+ </m3e-collapsible>`;
634
+ }
635
+ };
636
+ _M3eNavMenuItemElement_items = new WeakMap();
637
+ _M3eNavMenuItemElement_menu = new WeakMap();
638
+ _M3eNavMenuItemElement_path = new WeakMap();
639
+ _M3eNavMenuItemElement_link = new WeakMap();
640
+ _M3eNavMenuItemElement_instances = new WeakSet();
641
+ _M3eNavMenuItemElement_renderIcon = function _M3eNavMenuItemElement_renderIcon() {
642
+ const icon = html `<slot name="icon" @slotchange="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleIconSlotChange)}"></slot>`;
643
+ return this.selected && !this.hasChildItems
644
+ ? html `<slot name="selected-icon" @slotchange="${__classPrivateFieldGet(this, _M3eNavMenuItemElement_instances, "m", _M3eNavMenuItemElement_handleIconSlotChange)}">${icon}</slot>`
645
+ : icon;
646
+ };
647
+ _M3eNavMenuItemElement_handleIconSlotChange = function _M3eNavMenuItemElement_handleIconSlotChange(e) {
648
+ this.classList.toggle("-with-icon", hasAssignedNodes(e.target));
649
+ };
650
+ _M3eNavMenuItemElement_handleSlotChange = function _M3eNavMenuItemElement_handleSlotChange(e) {
651
+ __classPrivateFieldSet(this, _M3eNavMenuItemElement_link, e.target.assignedElements({ flatten: true }).find((x) => x instanceof HTMLAnchorElement) ??
652
+ null, "f");
653
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_link, "f")?.setAttribute("tabindex", "-1");
654
+ };
655
+ _M3eNavMenuItemElement_handleItemSlotChange = function _M3eNavMenuItemElement_handleItemSlotChange(e) {
656
+ __classPrivateFieldSet(this, _M3eNavMenuItemElement_items, e.target
657
+ .assignedElements({ flatten: true })
658
+ .filter((x) => x instanceof M3eNavMenuItemElement_1), "f");
659
+ const hadChildItems = this._hasChildItems;
660
+ this._hasChildItems = __classPrivateFieldGet(this, _M3eNavMenuItemElement_items, "f").length > 0;
661
+ this.classList.toggle("-has-items", this._hasChildItems);
662
+ if (hadChildItems || this._hasChildItems) {
663
+ this.selected = __classPrivateFieldGet(this, _M3eNavMenuItemElement_items, "f").some((x) => x.selected);
664
+ }
665
+ };
666
+ _M3eNavMenuItemElement_handleClick = function _M3eNavMenuItemElement_handleClick() {
667
+ if (this.disabled)
668
+ return;
669
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_menu, "f")?.[selectionManager].setActiveItem(this);
670
+ if (!this._hasChildItems) {
671
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_menu, "f")?.[selectionManager].select(this);
672
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_path, "f").forEach((x) => (x.selected = this.selected));
673
+ __classPrivateFieldGet(this, _M3eNavMenuItemElement_link, "f")?.click();
674
+ }
675
+ else {
676
+ this.toggle();
677
+ }
678
+ };
679
+ _M3eNavMenuItemElement_handleCollapsibleEvent = function _M3eNavMenuItemElement_handleCollapsibleEvent(e) {
680
+ e.stopPropagation();
681
+ this.dispatchEvent(new Event(e.type, { bubbles: true }));
682
+ };
683
+ /** The styles of the element. */
684
+ M3eNavMenuItemElement.styles = css `
685
+ :host {
686
+ display: block;
687
+ flex: none;
688
+ outline: none;
689
+ position: relative;
690
+ font-size: var(--m3e-nav-menu-item-font-size, ${DesignToken.typescale.standard.label.large.fontSize});
691
+ font-weight: var(--m3e-nav-menu-item-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});
692
+ line-height: var(--m3e-nav-menu-item-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});
693
+ letter-spacing: var(--m3e-nav-menu-item-tracking, ${DesignToken.typescale.standard.label.large.tracking});
694
+ }
695
+ .base {
696
+ display: flex;
697
+ align-items: center;
698
+ position: relative;
699
+ padding-inline: var(--m3e-nav-menu-item-padding, 1.5rem);
700
+ height: calc(var(--m3e-nav-menu-item-height, 3.5rem) + ${DesignToken.density.calc(-3)});
701
+ column-gap: var(--m3e-nav-menu-item-spacing, 0.75rem);
702
+ transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard},
703
+ background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
704
+ }
705
+ .base,
706
+ .focus-ring {
707
+ border-radius: var(--m3e-nav-menu-item-shape, ${DesignToken.shape.corner.full});
708
+ }
709
+ .label {
710
+ flex: 1 1 auto;
711
+ display: flex;
712
+ align-items: center;
713
+ position: relative;
714
+ overflow: hidden;
715
+ vertical-align: middle;
716
+ }
717
+ .icon,
718
+ .toggle {
719
+ flex: none;
720
+ display: flex;
721
+ align-items: center;
722
+ justify-content: center;
723
+ position: relative;
724
+ vertical-align: middle;
725
+ }
726
+ ::slotted([slot="badge"]) {
727
+ flex: none;
728
+ position: relative;
729
+ font-size: var(--m3e-nav-menu-item-badge-font-size, ${DesignToken.typescale.standard.label.large.fontSize});
730
+ font-weight: var(--m3e-nav-menu-item-badge-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});
731
+ line-height: var(--m3e-nav-menu-item-badge-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});
732
+ letter-spacing: var(--m3e-nav-menu-badge-item-tracking, ${DesignToken.typescale.standard.label.large.tracking});
733
+ }
734
+ .toggle {
735
+ transition: ${unsafeCSS(`transform var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
736
+ ${DesignToken.motion.easing.standard}`)};
737
+ }
738
+ :host(:not(.-with-icon)) .icon {
739
+ display: none;
740
+ }
741
+ .icon {
742
+ margin-inline-start: -0.5rem;
743
+ }
744
+ .toggle {
745
+ margin-inline-end: -0.5rem;
746
+ }
747
+ .group {
748
+ padding-inline-start: var(--m3e-nav-menu-item-inset, 1rem);
749
+ }
750
+ :host([open]) .toggle {
751
+ transform: rotate(180deg);
752
+ }
753
+ :host(:not(.-has-items)) .toggle,
754
+ :host(:not(.-has-items)) .group {
755
+ display: none;
756
+ }
757
+ ::slotted([slot="selected-icon"]),
758
+ ::slotted([slot="icon"]),
759
+ ::slotted([slot="toggle-icon"]),
760
+ .toggle-icon {
761
+ vertical-align: middle;
762
+ width: 1em;
763
+ height: 1em;
764
+ font-size: var(--m3e-nav-menu-item-icon-size, 1.5rem);
765
+ }
766
+ :host(:not(:disabled)) .base {
767
+ cursor: pointer;
768
+ }
769
+ :host(:not(:disabled)) .base {
770
+ color: var(--m3e-nav-menu-item-label-color, ${DesignToken.color.onSurfaceVariant});
771
+ }
772
+ :host(:disabled) .base {
773
+ color: color-mix(
774
+ in srgb,
775
+ var(--m3e-nav-menu-item-disabled-color, ${DesignToken.color.onSurface})
776
+ var(--m3e-nav-menu-item-disabled-color-opacity, 38%),
777
+ transparent
778
+ );
779
+ }
780
+ :host([selected]:not(.-has-items):not(:disabled)) .base {
781
+ color: var(--m3e-nav-menu-item-selected-label-color, ${DesignToken.color.onSecondaryContainer});
782
+ background-color: var(--m3e-nav-menu-item-selected-container-color, ${DesignToken.color.secondaryContainer});
783
+ --m3e-state-layer-focus-color: var(
784
+ --m3e-nav-menu-item-selected-container-focus-color,
785
+ ${DesignToken.color.onSecondaryContainer}
786
+ );
787
+ --m3e-state-layer-hover-color: var(
788
+ --m3e-nav-menu-item-selected-container-hover-color,
789
+ ${DesignToken.color.onSecondaryContainer}
790
+ );
791
+ --m3e-ripple-color: var(--m3e-nav-menu-item-selected-ripple-color, ${DesignToken.color.onSecondaryContainer});
792
+ }
793
+ :host(:not([selected]):not(.-has-items):not(:disabled)) .base {
794
+ --m3e-state-layer-focus-color: var(
795
+ --m3e-nav-menu-item-unselected-container-focus-color,
796
+ ${DesignToken.color.onSurface}
797
+ );
798
+ --m3e-state-layer-hover-color: var(
799
+ --m3e-nav-menu-item-unselected-container-hover-color,
800
+ ${DesignToken.color.onSurface}
801
+ );
802
+ --m3e-ripple-color: var(--m3e-nav-menu-item-unselected-ripple-color, ${DesignToken.color.onSurface});
803
+ }
804
+ .state-layer {
805
+ margin-inline: auto;
806
+ }
807
+ :host([selected].-has-items:not(:disabled)) .base {
808
+ background-color: var(--m3e-nav-menu-item-open-container-color, ${DesignToken.color.surfaceContainerHighest});
809
+ --m3e-state-layer-focus-color: var(
810
+ --m3e-nav-menu-item-open-container-focus-color,
811
+ ${DesignToken.color.onSurface}
812
+ );
813
+ --m3e-state-layer-hover-color: var(
814
+ --m3e-nav-menu-item-open-container-hover-color,
815
+ ${DesignToken.color.onSurface}
816
+ );
817
+ --m3e-ripple-color: var(--m3e-nav-menu-item-open-ripple-color, ${DesignToken.color.onSurface});
818
+ }
819
+ ::slotted(a[slot="label"]) {
820
+ all: unset;
821
+ }
822
+ ::slotted(m3e-divider) {
823
+ margin-block: var(--m3e-nav-menu-divider-margin, 0.25rem);
824
+ }
825
+ ::slotted(m3e-nav-menu-item:first-of-type) {
826
+ margin-block-start: var(--m3e-nav-menu-item-vertical-inset, 0.25rem);
827
+ }
828
+ ::slotted(m3e-nav-menu-item:last-of-type) {
829
+ margin-block-end: var(--m3e-nav-menu-item-vertical-inset, 0.25rem);
830
+ }
831
+ @media (prefers-reduced-motion) {
832
+ .base,
833
+ .toggle,
834
+ .state-layer {
835
+ transition: none !important;
836
+ }
837
+ }
838
+ @media (forced-colors: active) {
839
+ .base,
840
+ .state-layer {
841
+ transition: none !important;
842
+ }
843
+
844
+ :host(:disabled) .base {
845
+ color: GrayText;
846
+ }
847
+ :host(:not([selected]):not(:disabled)) .base {
848
+ color: ButtonText;
849
+ }
850
+ :host([selected]:not(.-has-items):not(:disabled)) .base {
851
+ forced-color-adjust: none;
852
+ color: ButtonFace;
853
+ background-color: ButtonText;
854
+ }
855
+ :host([selected].-has-items:not(:disabled)) .base {
856
+ background-color: unset;
857
+ color: ButtonText;
858
+ }
859
+ }
860
+ `;
861
+ __decorate([
862
+ e$1(".state-layer")
863
+ ], M3eNavMenuItemElement.prototype, "stateLayer", void 0);
864
+ __decorate([
865
+ e$1(".focus-ring")
866
+ ], M3eNavMenuItemElement.prototype, "focusRing", void 0);
867
+ __decorate([
868
+ e$1(".ripple")
869
+ ], M3eNavMenuItemElement.prototype, "ripple", void 0);
870
+ __decorate([
871
+ e$1(".base")
872
+ ], M3eNavMenuItemElement.prototype, "_base", void 0);
873
+ __decorate([
874
+ r$1()
875
+ ], M3eNavMenuItemElement.prototype, "_hasChildItems", void 0);
876
+ __decorate([
877
+ n$1({ type: Boolean, reflect: true })
878
+ ], M3eNavMenuItemElement.prototype, "open", void 0);
879
+ M3eNavMenuItemElement = M3eNavMenuItemElement_1 = __decorate([
880
+ t$2("m3e-nav-menu-item")
881
+ ], M3eNavMenuItemElement);
882
+
883
+ export { M3eNavMenuElement, M3eNavMenuItemElement };
884
+ //# sourceMappingURL=index.js.map