@m3e/menu 1.0.3 → 1.0.5
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.min.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2025 matraic
|
|
4
4
|
* See LICENSE file in the project root for full license text.
|
|
5
5
|
*/
|
|
6
|
-
import{LitElement as e,nothing as t,html as s,css as i,unsafeCSS as n}from"lit";import{KeyboardClick as o,Focusable as r,AttachInternals as a,Disabled as
|
|
6
|
+
import{LitElement as e,nothing as t,html as s,css as i,unsafeCSS as n}from"lit";import{KeyboardClick as o,Focusable as r,AttachInternals as a,Disabled as l,isLinkButtonMixin as c,renderPseudoLink as h,DesignToken as d,HtmlFor as u,LinkButton as m,Role as p,HoverController as f,hasAssignedNodes as v,ScrollController as b,Checked as g}from"@m3e/core";import{addAriaReferencedId as y,removeAriaReferencedId as w,RovingTabIndexManager as E}from"@m3e/core/a11y";import{positionAnchor as k}from"@m3e/core/anchoring";function $(e,t,s,i){var n,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,s,r):n(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r}function S(e,t,s,i){if("a"===s&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(e):i?i.value:t.get(e)}function _(e,t,s,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,s):n?n.value=s:t.set(e,s),s}"function"==typeof SuppressedError&&SuppressedError;
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
@@ -36,12 +36,12 @@ const J={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:K},V=(e=J,t,
|
|
|
36
36
|
* Copyright 2017 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
38
|
*/
|
|
39
|
-
function G(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,s),s))(t,s,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}class Q extends(o(r(a(
|
|
39
|
+
function G(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,s),s))(t,s,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}class Q extends(o(r(a(l(e),!0)))){get menu(){return this.closest("m3e-menu")}firstUpdated(e){super.firstUpdated(e),[this._focusRing,this._stateLayer,this._ripple].forEach(e=>e?.attach(this))}render(){return s`<div class="base">
|
|
40
40
|
<m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
|
|
41
41
|
<m3e-focus-ring class="focus-ring" inward ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
42
42
|
<m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple>
|
|
43
43
|
<div class="touch" aria-hidden="true"></div>
|
|
44
|
-
${
|
|
44
|
+
${c(this)?this[h]():t}
|
|
45
45
|
<div class="wrapper">${this._renderContent()}</div>
|
|
46
46
|
</div>`}}var ee,te,se;Q.styles=i`
|
|
47
47
|
:host {
|
|
@@ -50,6 +50,7 @@ function G(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
|
|
|
50
50
|
user-select: none;
|
|
51
51
|
flex: none;
|
|
52
52
|
height: var(--m3e-menu-item-container-height, 3rem);
|
|
53
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
53
54
|
}
|
|
54
55
|
:host(:not(:focus-visible)) .base {
|
|
55
56
|
--m3e-state-layer-focus-opacity: 0;
|
|
@@ -146,19 +147,19 @@ function G(e,t){return(t,s,i)=>((e,t,s)=>(s.configurable=!0,s.enumerable=!0,Refl
|
|
|
146
147
|
color: GrayText;
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
|
-
`,$([G(".focus-ring")],Q.prototype,"_focusRing",void 0),$([G(".state-layer")],Q.prototype,"_stateLayer",void 0),$([G(".ripple")],Q.prototype,"_ripple",void 0);let ie=class extends(u(e)){constructor(){super(...arguments),ee.add(this),te.set(this,async e=>S(this,ee,"m",se).call(this,e))}get menu(){return"M3E-MENU"===this.control?.tagName?this.control:null}connectedCallback(){super.connectedCallback(),this.parentElement?.addEventListener("click",S(this,te,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.parentElement?.removeEventListener("click",S(this,te,"f"))}attach(e){super.attach(e);const t=this.menu;t&&(this.parentElement&&(this.parentElement.ariaHasPopup="menu",this.parentElement.ariaExpanded="false",t.id&&y(this.parentElement,"aria-controls",t.id)),this.closest("m3e-menu")&&(t.submenu=!0))}detach(){if(this.parentElement){this.parentElement.ariaHasPopup=null,this.parentElement.ariaExpanded=null;const e=this.menu;e?.id&&w(this.parentElement,"aria-controls",e.id)}super.detach()}render(){return s`<slot></slot>`}};var ne,oe,re,ae,ce,
|
|
150
|
+
`,$([G(".focus-ring")],Q.prototype,"_focusRing",void 0),$([G(".state-layer")],Q.prototype,"_stateLayer",void 0),$([G(".ripple")],Q.prototype,"_ripple",void 0);let ie=class extends(u(e)){constructor(){super(...arguments),ee.add(this),te.set(this,async e=>S(this,ee,"m",se).call(this,e))}get menu(){return"M3E-MENU"===this.control?.tagName?this.control:null}connectedCallback(){super.connectedCallback(),this.parentElement?.addEventListener("click",S(this,te,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.parentElement?.removeEventListener("click",S(this,te,"f"))}attach(e){super.attach(e);const t=this.menu;t&&(this.parentElement&&(this.parentElement.ariaHasPopup="menu",this.parentElement.ariaExpanded="false",t.id&&y(this.parentElement,"aria-controls",t.id)),this.closest("m3e-menu")&&(t.submenu=!0))}detach(){if(this.parentElement){this.parentElement.ariaHasPopup=null,this.parentElement.ariaExpanded=null;const e=this.menu;e?.id&&w(this.parentElement,"aria-controls",e.id)}super.detach()}render(){return s`<slot></slot>`}};var ne,oe,re,ae,le,ce,he,de,ue,me,pe,fe;te=new WeakMap,ee=new WeakSet,se=function(e){!e.defaultPrevented&&this.parentElement&&("M3E-MENU-ITEM"===this.parentElement.tagName?this.menu?.show(this.parentElement):this.menu?.toggle(this.parentElement))},ie.styles=i`
|
|
150
151
|
:host {
|
|
151
152
|
display: contents;
|
|
152
153
|
}
|
|
153
154
|
::slotted(.material-icons) {
|
|
154
155
|
font-size: inherit !important;
|
|
155
156
|
}
|
|
156
|
-
`,ie=$([C("m3e-menu-trigger")],ie);let ve=fe=class extends(m(p(Q,"menuitem"))){constructor(){super(),ne.add(this),oe.set(this,e=>S(this,ne,"m",ue).call(this,e)),re.set(this,e=>S(this,ne,"m",me).call(this,e)),ae.set(this,()=>S(this,ne,"m",pe).call(this)),this._hasSubmenu=!1,
|
|
157
|
-
<span class="content"><slot @slotchange="${S(this,ne,"m",
|
|
157
|
+
`,ie=$([C("m3e-menu-trigger")],ie);let ve=fe=class extends(m(p(Q,"menuitem"))){constructor(){super(),ne.add(this),oe.set(this,e=>S(this,ne,"m",ue).call(this,e)),re.set(this,e=>S(this,ne,"m",me).call(this,e)),ae.set(this,()=>S(this,ne,"m",pe).call(this)),this._hasSubmenu=!1,le.set(this,void 0),new f(this,{startDelay:500,endDelay:500,callback:e=>{e&&!this.disabled&&S(this,le,"f")&&S(this,le,"f").menu?.show(this)}})}get submenu(){return S(this,le,"f")?.menu??null}connectedCallback(){super.connectedCallback(),this.addEventListener("click",S(this,oe,"f")),this.addEventListener("keydown",S(this,re,"f")),this.addEventListener("mouseenter",S(this,ae,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",S(this,oe,"f")),this.removeEventListener("keydown",S(this,re,"f")),this.removeEventListener("mouseenter",S(this,ae,"f"))}_renderContent(){return s`<slot name="icon" aria-hidden="true" @slotchange="${S(this,ne,"m",he)}"></slot>
|
|
158
|
+
<span class="content"><slot @slotchange="${S(this,ne,"m",ce)}"></slot></span>
|
|
158
159
|
${this._hasSubmenu?s`<svg class="trailing-icon" aria-hidden="true" viewBox="0 -960 960 960" fill="currentColor">
|
|
159
160
|
<path d="M400-280v-400l200 200-200 200Z" />
|
|
160
161
|
</svg>`:s`<slot name="trailing-icon" aria-hidden="true" @slotchange="${S(this,ne,"m",de)}">
|
|
161
|
-
</slot>`}`}};var be,ge,ye,we,Ee,ke,$e,Se,_e,Ce,Pe,xe,Le;oe=new WeakMap,re=new WeakMap,ae=new WeakMap,
|
|
162
|
+
</slot>`}`}};var be,ge,ye,we,Ee,ke,$e,Se,_e,Ce,Pe,xe,Le;oe=new WeakMap,re=new WeakMap,ae=new WeakMap,le=new WeakMap,ne=new WeakSet,ce=function(e){_(this,le,e.target.assignedElements({flatten:!0}).find(e=>e instanceof ie),"f"),this._hasSubmenu=void 0!==S(this,le,"f")},he=function(e){this.classList.toggle("-with-icon",v(e.target))},de=function(e){this.classList.toggle("-with-trailing-icon",v(e.target))},ue=function(e){e.defaultPrevented||this._hasSubmenu||this.menu?.hideAll(!0)},me=function(e){if(!e.defaultPrevented&&!this.disabled)switch(e.key){case"Right":case"ArrowRight":e.preventDefault(),this.submenu?.show(this)}},pe=function(){this.menu?.items.forEach(e=>{e instanceof fe&&e!==this&&e.submenu?.isOpen&&e.submenu.hide()})},$([function(e){return F({...e,state:!0,attribute:!1})}
|
|
162
163
|
/**
|
|
163
164
|
* @license
|
|
164
165
|
* Copyright 2017 Google LLC
|