@data-slot/navigation-menu 0.2.132 → 0.2.134
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.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=[`start`,`center`,`end`],n=[`top`,`right`,`bottom`,`left`],r=(e,t)=>t===`start`?{x:e.left,y:e.top}:t===`end`?{x:e.right,y:e.bottom}:{x:e.left+e.width/2,y:e.top+e.height/2},i=(e,t,n)=>{let i=r(n,t);return e===`top`?{x:i.x,y:n.top}:e===`bottom`?{x:i.x,y:n.bottom}:e===`left`?{x:n.left,y:i.y}:{x:n.right,y:i.y}},a=`@data-slot/navigation-menu`;function o(r,o={}){let s=(0,e.reuseRootBinding)(r,a,`[@data-slot/navigation-menu] createNavigationMenu() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(s)return s;let c=o.delayOpen??(0,e.getDataNumber)(r,`delayOpen`)??0,l=o.delayClose??(0,e.getDataNumber)(r,`delayClose`)??0,u=o.openOnFocus??(0,e.getDataBool)(r,`openOnFocus`)??!1,d=o.side??(0,e.getDataEnum)(r,`side`,n)??`bottom`,f=o.align??(0,e.getDataEnum)(r,`align`,t)??`start`,p=o.sideOffset??(0,e.getDataNumber)(r,`sideOffset`)??0,m=o.alignOffset??(0,e.getDataNumber)(r,`alignOffset`)??0,h=o.safeTriangle??(0,e.getDataBool)(r,`safeTriangle`)??!1,g=o.debugSafeTriangle??(0,e.getDataBool)(r,`debugSafeTriangle`)??!1,ee=h||g,te=o.onValueChange,ne=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),_=(e,t)=>{`inert`in e&&(e.inert=t)},v=(0,e.getPart)(r,`navigation-menu-list`),y=(0,e.getParts)(r,`navigation-menu-item`),b=(0,e.getPart)(r,`navigation-menu-viewport`),x=(0,e.getPart)(r,`navigation-menu-indicator`),S=(e,t)=>{let n=e.parentElement;for(;n&&n!==r;){if(n.getAttribute(`data-slot`)===t)return n;n=n.parentElement}return null};if(!v||y.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let C=null,w=null,T=-1,re=null,ie=null,E=null,D=!1,O=null,k=null,A=!1,j=!1,M=null,N=null,P=0,F=0,I=[],L=new Map,R=new Map,ae=b?S(b,`navigation-menu-viewport-positioner`):null,oe=b?S(b,`navigation-menu-positioner`):null,z=ae??oe,se=z?S(z,`navigation-menu-portal`):null,B=b?(0,e.createPortalLifecycle)({content:b,root:r,enabled:!0,wrapperSlot:z?void 0:`navigation-menu-viewport-positioner`,container:z??void 0,mountTarget:z?se??z:void 0}):null,ce=()=>{let e=B?.container;e instanceof HTMLElement&&(e.style.position=``,e.style.top=``,e.style.left=``,e.style.width=``,e.style.height=``,e.style.margin=``,e.style.willChange=``,e.style.pointerEvents=``,e.style.transform=``,e.style.removeProperty(`--transform-origin`),e.removeAttribute(`data-instant`))},V=()=>{b?.removeAttribute(`data-instant`);let e=B?.container;e instanceof HTMLElement&&e.removeAttribute(`data-instant`)},le=b?(0,e.createPresenceLifecycle)({element:b,onExitComplete:()=>{j||(V(),ce(),P=0,F=0,B?.restore(),b.hidden=!0,b.style.pointerEvents=`none`)}}):null,ue=e=>{if(!b)return;let t=R.get(e)??{originalParent:null,originalNextSibling:null,mountedInViewport:!1};t.mountedInViewport||(t.originalParent=e.parentNode,t.originalNextSibling=e.nextSibling,t.mountedInViewport=!0,R.set(e,t)),e.parentNode!==b&&b.appendChild(e)},de=e=>{let t=R.get(e);if(!t||!t.mountedInViewport)return;let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.mountedInViewport=!1,t.originalParent=null,t.originalNextSibling=null},fe=()=>{if(!b||!B)return;let e=B.container,t=r.ownerDocument.defaultView??window,n=r.getBoundingClientRect(),i=n.top+t.scrollY+F,a=n.left+t.scrollX+P;e.style.position=`absolute`,e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.margin=`0`,e.style.willChange=`top,left`,e.style.pointerEvents=`none`},H=null,pe=e=>{H?.disconnect(),H=null,!(!b||!e)&&(H=new ResizeObserver(()=>{let t=me(e.item,e.content);Xe(e.content,e.trigger,t)}),H.observe(e.content))};I.push(()=>H?.disconnect()),I.push(()=>{V(),L.forEach(e=>e.cleanup()),L.clear(),R.forEach((e,t)=>{de(t),t.hidden=!0,t.style.pointerEvents=`none`}),R.clear(),ce(),P=0,F=0,le?.cleanup(),B?.cleanup()});let U=new Map,me=(r,i)=>({side:o.side??(0,e.getDataEnum)(i,`side`,n)??(0,e.getDataEnum)(r,`side`,n)??d,align:o.align??(0,e.getDataEnum)(i,`align`,t)??(0,e.getDataEnum)(r,`align`,t)??f,sideOffset:o.sideOffset??(0,e.getDataNumber)(i,`sideOffset`)??(0,e.getDataNumber)(r,`sideOffset`)??p,alignOffset:o.alignOffset??(0,e.getDataNumber)(i,`alignOffset`)??(0,e.getDataNumber)(r,`alignOffset`)??m}),he=0;y.forEach(t=>{let n=t.dataset.value;if(!n)return;let r=(0,e.getPart)(t,`navigation-menu-trigger`),i=(0,e.getPart)(t,`navigation-menu-content`);if(r&&i){U.set(n,{value:n,item:t,trigger:r,content:i,index:he++}),L.set(i,(0,e.createPresenceLifecycle)({element:i,onExitComplete:()=>{j||(de(i),i.hidden=!0,i.style.pointerEvents=`none`)}}));let a=ne(n),o=(0,e.ensureId)(r,`nav-menu-trigger-${a}`),s=(0,e.ensureId)(i,`nav-menu-content-${a}`);r.setAttribute(`aria-haspopup`,`true`),r.setAttribute(`aria-controls`,s),i.setAttribute(`aria-labelledby`,o)}}),Array.from(U.values()).map(e=>e.trigger);let ge=`a[href], button:not([disabled]), [role="link"], [role="button"], [tabindex]:not([tabindex="-1"])`,_e=e=>{let t=e?.closest(`[data-slot="navigation-menu-item"]`);if(!t)return null;let n=t.dataset.value;if(!n)return null;let r=U.get(n);return!r||r.item!==t?null:r},ve=e=>{if(e.matches(ge))return e;let t=e.querySelectorAll(ge);for(let n of t)if(e.contains(n)&&!n.closest(`[data-slot="navigation-menu-content"]`)&&!(n.hidden||n.closest(`[hidden]`)))return n;return null},W=[],ye=new Map;y.forEach(e=>{let t=_e(e);if(t){let e={kind:`submenu`,element:t.trigger,value:t.value,trigger:t.trigger};W.push(e),ye.set(e.element,e);return}let n=ve(e);if(!n)return;let r={kind:`plain`,element:n};W.push(r),ye.set(r.element,r)});let be=e=>{let t=e instanceof HTMLElement?e:null;if(!t)return null;let n=t;for(;n&&n!==v;){let e=ye.get(n);if(e)return e;n=n.parentElement}return null},xe=e=>{let t=be(e);return t?.kind===`plain`?t:null},Se=(e,t={})=>{let n=r.ownerDocument,i=t.preserveOpenOnPlain??!1;return e.kind===`submenu`?(e.trigger.focus(),n.activeElement===e.trigger?(Z(e.trigger),!0):!1):(C!==null&&!i&&$(),e.element.focus(),n.activeElement===e.element?(C!==null&&i?Z():X(e.element),!0):!1)},Ce=(e,t,n={})=>{for(let r=e+t;r>=0&&r<W.length;r+=t){let e=W[r];if(e&&Se(e,n))return!0}return!1},we=(e,t,n={})=>{let r=W.indexOf(e);return r===-1?!1:Ce(r,t,n)},Te=(e,t,n={})=>{let r=W.findIndex(t=>t.kind===`submenu`&&t.trigger===e);return r===-1?!1:Ce(r,t,n)},Ee=e=>{if(!(e instanceof Node)||!v.contains(e))return!1;let t=e instanceof HTMLElement?e:e.parentElement;return!t||t.closest(`[data-slot="navigation-menu-indicator"]`)||_e(t)?!1:t.closest(`[data-slot="navigation-menu-item"]`)?!0:!!t.closest(`a[href], button, [role='link'], [role='button']`)},De=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,Oe=e=>Array.from(e.querySelectorAll(De)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),ke=e=>!e.isConnected||e.hidden||e.closest(`[hidden]`)||`disabled`in e&&e.disabled||e.getAttribute(`aria-hidden`)===`true`||e.getAttribute(`tabindex`)===`-1`?!1:e.matches(De)?!0:e.tabIndex>=0,Ae=e=>{if(r.contains(e)||b?.contains(e))return!0;let t=B?.container;if(t instanceof HTMLElement&&t.contains(e))return!0;for(let{content:t}of U.values())if(t.contains(e))return!0;return!1},je=()=>{let e=r.ownerDocument,t=Array.from(e.querySelectorAll(`*`));for(let n of t)if(ke(n)&&!Ae(n)&&(r.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0&&(n.focus(),e.activeElement===n))return!0;return!1},Me=e=>{requestAnimationFrame(()=>{if(C!==e)return;let t=U.get(e);if(!t)return;let n=Oe(t.content)[0];n?n.focus():t.content.focus()})},G=()=>{re&&=(clearTimeout(re),null),ie&&=(clearTimeout(ie),null)},Ne=()=>{N!==null&&(cancelAnimationFrame(N),N=null)},K=null,Pe=()=>{if(!b)return null;let e=B?.container;return e instanceof HTMLElement?e:b.parentElement instanceof HTMLElement?b.parentElement:b},Fe=()=>{let t=Pe();return K||(K=document.createElement(`div`),K.setAttribute(`data-slot`,`navigation-menu-bridge`),K.style.cssText=`position: absolute; pointer-events: auto; z-index: 0; display: none;`,I.push((0,e.on)(K,`pointerenter`,()=>{G()}),(0,e.on)(K,`pointerleave`,t=>{if(D||C===null)return;let n=t.relatedTarget;Y(n)||n&&(0,e.containsWithPortals)(r,n)||(Q(null),X(null))}))),t&&K.parentElement!==t&&t.insertBefore(K,t.firstChild),K},q=()=>{K&&(K.style.height=`0`,K.style.width=`0`,K.style.top=`0px`,K.style.left=`0px`,K.style.right=`0px`,K.style.bottom=`auto`,K.style.transform=`none`,K.style.clipPath=`none`,K.style.display=`none`)},Ie=()=>{if(!g)return null;let e=r.ownerDocument.body;return e?(M||(M=r.ownerDocument.createElement(`div`),M.setAttribute(`data-slot`,`navigation-menu-safe-triangle`),M.style.cssText=[`position: fixed`,`pointer-events: none`,`display: none`,`z-index: 2147483647`,`background: rgba(255, 0, 0, 0.18)`,`border: 1px solid rgba(255, 0, 0, 0.45)`].join(`; `)),M.parentElement!==e&&e.appendChild(M),M):null},Le=()=>{M&&(M.style.width=`0`,M.style.height=`0`,M.style.clipPath=`none`,M.style.display=`none`)},J=()=>{g||Le()},Re=e=>{let t=Ie();if(!t)return;let n=e.apex.x,r=e.apex.y,i=e.edgeA.x,a=e.edgeA.y,o=e.edgeB.x,s=e.edgeB.y,c=Math.min(n,i,o),l=Math.min(r,a,s),u=Math.max(n,i,o),d=Math.max(r,a,s),f=Math.max(1,u-c),p=Math.max(1,d-l),m=(e,t)=>`${(e-c)/f*100}% ${(t-l)/p*100}%`;t.style.display=`block`,t.style.left=`${c}px`,t.style.top=`${l}px`,t.style.width=`${f}px`,t.style.height=`${p}px`,t.style.clipPath=`polygon(${m(n,r)}, ${m(i,a)}, ${m(o,s)})`},ze=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),Be=(e,t,n,r)=>{let i=ze(e,t,n),a=ze(e,n,r),o=ze(e,r,t);return!((i<0||a<0||o<0)&&(i>0||a>0||o>0))},Ve=(e,t,n)=>{let r=.5;if(n.top>=t.bottom-r)return[{x:n.left,y:n.top},{x:n.right,y:n.top}];if(n.bottom<=t.top+r)return[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}];if(n.left>=t.right-r)return[{x:n.left,y:n.top},{x:n.left,y:n.bottom}];if(n.right<=t.left+r)return[{x:n.right,y:n.top},{x:n.right,y:n.bottom}];let i=[[{x:n.left,y:n.top},{x:n.right,y:n.top}],[{x:n.right,y:n.top},{x:n.right,y:n.bottom}],[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}],[{x:n.left,y:n.top},{x:n.left,y:n.bottom}]],a=([t,n])=>t.y===n.y?Math.abs(e.y-t.y):Math.abs(e.x-t.x),o=i[0],s=a(o);for(let e=1;e<i.length;e++){let t=i[e],n=a(t);n<s&&(o=t,s=n)}return o},He=()=>C?U.get(C)??null:null,Ue=(e,t,n)=>{if(n.width<=0||n.height<=0)return null;let r={x:e.left+e.width/2,y:e.top+e.height*.62},[i,a]=Ve(r,t,n);if(i.x===a.x){let e=Math.min(i.y,a.y),t=Math.max(i.y,a.y),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:i.x,y:e+r},a={x:a.x,y:t-r}}else{let e=Math.min(i.x,a.x),t=Math.max(i.x,a.x),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:e+r,y:i.y},a={x:t-r,y:a.y}}return{apex:r,edgeA:i,edgeB:a}},We=()=>{if(!ee||!b||C===null)return null;let e=He();if(!e)return null;let t=r.getBoundingClientRect(),n=e.trigger.getBoundingClientRect(),i=b.getBoundingClientRect(),a=e.content.getBoundingClientRect();return Ue(n,t,i.width>0&&i.height>0?i:a)},Ge=e=>{let t=We();return t?Be({x:e.clientX,y:e.clientY},t.apex,t.edgeA,t.edgeB):!1},Ke=(e,t)=>({x:e.x-t.left,y:e.y-t.top}),qe=e=>{if(e.length<=1)return e.slice();let t=e=>`${e.x.toFixed(3)}:${e.y.toFixed(3)}`,n=new Map;for(let r of e)n.set(t(r),r);let r=Array.from(n.values()).sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x);if(r.length<=2)return r;let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=[];for(let e of r){for(;a.length>=2&&i(a[a.length-2],a[a.length-1],e)<=0;)a.pop();a.push(e)}let o=[];for(let e=r.length-1;e>=0;e--){let t=r[e];for(;o.length>=2&&i(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return a.pop(),o.pop(),a.concat(o)},Je=e=>{if(e.length<3){q();return}let t=Fe(),n=t.parentElement,r=qe(n&&n===B?.container?e.map(e=>({x:e.x-P,y:e.y-F})):e);if(r.length<3){q();return}let i=Math.min(...r.map(e=>e.x)),a=Math.min(...r.map(e=>e.y)),o=Math.max(...r.map(e=>e.x)),s=Math.max(...r.map(e=>e.y)),c=Math.max(1,o-i),l=Math.max(1,s-a),u=e=>`${(e.x-i)/c*100}% ${(e.y-a)/l*100}%`;t.style.display=`block`,t.style.transform=`none`,t.style.bottom=`auto`,t.style.right=`auto`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.width=`${c}px`,t.style.height=`${l}px`,t.style.clipPath=`polygon(${r.map(u).join(`, `)})`},Ye=()=>{if(!g)return;let e=We();if(!e){Le();return}Re(e)},Y=e=>{if(!e)return!1;if(He()?.content.contains(e)||b?.contains(e)||K?.contains(e))return!0;let t=B?.container;return!!(t instanceof HTMLElement&&t.contains(e))};I.push(J),I.push(Ne),I.push(q),I.push(()=>{Le(),M?.parentElement&&M.parentElement.removeChild(M),M=null});let Xe=(t,a,o)=>{b&&requestAnimationFrame(()=>{let s=t.firstElementChild,c=t.lastElementChild,l=s?getComputedStyle(s):null,u=c?getComputedStyle(c):null,d=l&&parseFloat(l.marginTop)||0,f=u&&parseFloat(u.marginBottom)||0,p=(...e)=>{let t=0;for(let n of e)Number.isFinite(n)&&(t=Math.max(t,n));return t},m=t.getBoundingClientRect(),h=p(m.width,t.scrollWidth,t.offsetWidth,t.clientWidth),g=p(m.height,t.scrollHeight,t.offsetHeight,t.clientHeight)+d+f,te={top:m.top,left:m.left,width:h,height:g,right:m.left+h,bottom:m.top+g},ne=getComputedStyle(b),_=parseFloat(ne.marginTop)||0;b.style.setProperty(`--viewport-width`,`${h}px`),b.style.setProperty(`--viewport-height`,`${g}px`);let v=r.getBoundingClientRect(),y=a.getBoundingClientRect(),x=(0,e.computeFloatingPosition)({anchorRect:y,contentRect:te,side:o.side,align:o.align,sideOffset:o.sideOffset,alignOffset:o.alignOffset,avoidCollisions:!1,collisionPadding:0,allowedSides:n}),S=x.x-v.left,C=x.y-v.top;P=S,F=C;let w=i(x.side,x.align,y),T=w.x-(v.left+S),re=w.y-(v.top+C),ie=w.x-v.left,E=w.y-v.top,D=`${T}px ${re}px`,O=`${ie}px ${E}px`;b.style.top=`0px`,b.style.left=`0px`,b.style.willChange=`transform,width,height`,b.style.setProperty(`--transform-origin`,D),t.style.top=`0px`,t.style.left=`0px`,t.style.setProperty(`--transform-origin`,D),b.setAttribute(`data-side`,x.side),b.setAttribute(`data-align`,x.align),t.setAttribute(`data-side`,x.side),t.setAttribute(`data-align`,x.align);let k=B?.container;k&&k!==b&&(k.setAttribute(`data-side`,x.side),k.setAttribute(`data-align`,x.align),k.style.setProperty(`--transform-origin`,O)),fe();let A=b.getBoundingClientRect(),j=[],M=Math.max(0,A.top-v.bottom),N=Math.max(0,v.top-A.bottom),I=Math.max(0,A.left-v.right),L=Math.max(0,v.left-A.right),R=Math.max(0,d+_),ae=Math.max(M,N,R),oe=Math.max(I,L),z=ee?Ue(y,v,A):null,se=(e,t,n,r)=>{n<=0||r<=0||j.push({x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r})};if(ae>=oe&&ae>0){let e=Math.max(M,N,R),t=S,n=N>M&&N>=R?C+g:C-e,r=h;if(z){let e=Math.min(z.edgeA.x,z.edgeB.x)-v.left,n=Math.max(z.edgeA.x,z.edgeB.x)-v.left;t=e-8,r=n-e+16}se(t,n,r,e)}else if(oe>0){let e=Math.max(I,L),t=C,n=L>I?S+h:S-e,r=g;if(z){let e=Math.min(z.edgeA.y,z.edgeB.y)-v.top,n=Math.max(z.edgeA.y,z.edgeB.y)-v.top;t=e-8,r=n-e+16}se(n,t,e,r)}if(z){let e=Ke(z.apex,v),t=Ke(z.edgeA,v),n=Ke(z.edgeB,v);j.push(e,t,n)}Je(j),Ye()})},Ze=e=>T===-1||e>T?`right`:`left`,X=e=>{if(!x)return;if(E=e,!e){Ne(),x.removeAttribute(`data-instant`),x.setAttribute(`data-state`,`hidden`);return}x.getAttribute(`data-state`)!==`visible`&&(Ne(),x.setAttribute(`data-instant`,``),N=requestAnimationFrame(()=>{N=requestAnimationFrame(()=>{x.removeAttribute(`data-instant`),N=null})}));let t=v.getBoundingClientRect(),n=e.getBoundingClientRect();x.style.setProperty(`--indicator-left`,`${n.left-t.left}px`),x.style.setProperty(`--indicator-width`,`${n.width}px`),x.style.setProperty(`--indicator-top`,`${n.top-t.top}px`);let r=(b&&parseFloat(getComputedStyle(b).marginTop)||0)<1?1:0;x.style.setProperty(`--indicator-height`,`${n.height-r}px`),x.setAttribute(`data-state`,`visible`)},Qe=()=>C?U.get(C)?.trigger??null:null,Z=(e=null)=>{let t=Qe();if(t){X(t);return}X(e)},Q=(t,n=!1)=>{if(J(),t===C){G();return}if(t!==null&&t===w){G();return}G(),w=t===null?null:t;let i=()=>{let n=C,i=t?U.get(t):null,a=n!==null&&t!==null&&n!==t,o=a&&i?Ze(i.index):null,s=document.activeElement;if(t===null&&s&&n){let t=U.get(n);t&&(0,e.containsWithPortals)(t.content,s)&&t.trigger.focus()}if(U.forEach(({trigger:r,content:i,item:a},s)=>{let c=s===t,l=s===n;if((0,e.setAria)(r,`expanded`,c),r.setAttribute(`data-state`,c?`open`:`closed`),a.setAttribute(`data-state`,c?`open`:`closed`),!c){let e=L.get(i);if(i.setAttribute(`data-state`,`inactive`),i.setAttribute(`aria-hidden`,`true`),_(i,!0),i.style.pointerEvents=`none`,l&&o){let e=o===`right`?`to-left`:`to-right`;i.setAttribute(`data-motion`,e)}else l&&i.removeAttribute(`data-motion`);l?e?.exit():e?.isExiting||(i.removeAttribute(`data-motion`),de(i),i.hidden=!0)}}),i){if(B?.mount(),b&&(b.hidden=!1),n===null&&le?.enter(),ue(i.content),L.get(i.content)?.enter(),o){let e=o===`right`?`from-right`:`from-left`;i.content.setAttribute(`data-motion`,e)}else i.content.removeAttribute(`data-motion`);i.content.setAttribute(`data-state`,`active`),i.content.removeAttribute(`aria-hidden`),_(i.content,!1),i.content.hidden=!1,i.content.style.pointerEvents=`auto`,T=i.index;let e=me(i.item,i.content);Xe(i.content,i.trigger,e),pe(i),X(i.trigger)}else q(),J(),le?.exit(),pe(null);let c=t!==null;if(r.setAttribute(`data-state`,c?`open`:`closed`),o?r.setAttribute(`data-motion`,o===`right`?`from-right`:`from-left`):r.removeAttribute(`data-motion`),b){b.setAttribute(`data-state`,c?`open`:`closed`),b.style.pointerEvents=c?`auto`:`none`;let e=B?.container;c&&!a?(b.setAttribute(`data-instant`,``),e?.setAttribute(`data-instant`,``)):a?V():c||V(),o&&b.style.setProperty(`--motion-direction`,o===`right`?`1`:`-1`)}C=t,w=null,t===null&&X(null),Ye(),(0,e.emit)(r,`navigation-menu:change`,{value:t}),te?.(t)};n?i():t!==null&&C===null?re=setTimeout(i,c):t!==null&&C!==null?i():ie=setTimeout(i,l)};r.setAttribute(`data-state`,`closed`),b&&(b.setAttribute(`data-state`,`closed`),b.hidden=!0,b.style.pointerEvents=`none`),x&&x.setAttribute(`data-state`,`hidden`),U.forEach(({trigger:t,content:n,item:r})=>{t.tagName===`BUTTON`&&!t.hasAttribute(`type`)&&(t.type=`button`),(0,e.setAria)(t,`expanded`,!1),t.setAttribute(`data-state`,`closed`),t.tabIndex=0,r.setAttribute(`data-state`,`closed`),n.setAttribute(`data-state`,`inactive`),n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1,_(n,!0),n.hidden=!0,n.style.pointerEvents=`none`}),U.forEach(({item:t,trigger:n},i)=>{I.push((0,e.on)(n,`pointerenter`,e=>{if(!D){if(C!==i&&Ge(e))return;X(n)}})),I.push((0,e.on)(t,`pointerenter`,e=>{if(!D){if(C!==i&&Ge(e))return;Q(i)}})),I.push((0,e.on)(t,`pointerleave`,t=>{if(w===i&&C===null&&(G(),w=null),C===i&&!D){let n=t.relatedTarget;if(Y(n))return;(!n||!(0,e.containsWithPortals)(r,n))&&(Q(null),X(null))}})),I.push((0,e.on)(n,`focus`,()=>{if(O===n){O=null;return}u&&Q(i,!0),Z(n)})),I.push((0,e.on)(n,`pointerdown`,()=>{O=n,k=n}),(0,e.on)(n,`keydown`,()=>{k=null})),I.push((0,e.on)(n,`click`,()=>{let e=k===n;k=null,O=null,G(),C===i&&D?(D=!1,Q(null,!0),X(null)):C===i&&!D?(D=!0,X(n),e||Me(i)):(D=!0,Q(i,!0),X(n),e||Me(i))}))}),I.push((0,e.on)(v,`pointerover`,e=>{let t=e;if(t.pointerType===`touch`)return;let n=xe(t.target);if(n){if(C!==null){if(D)return;$()}X(n.element);return}C!==null&&(D||Ee(t.target)&&$())}),(0,e.on)(v,`click`,e=>{C!==null&&Ee(e.target)&&$()})),I.push((0,e.on)(v,`focusin`,e=>{let t=xe(e.target);if(t){if(C!==null){Z();return}X(t.element)}}),(0,e.on)(r,`pointerenter`,()=>{A=!0}),(0,e.on)(r,`pointerleave`,e=>{let t=e.relatedTarget;if(!Y(t)&&(A=!1,!D)){if(Ge(e)){G();return}Q(null),X(null)}}),(0,e.on)(r,`pointerdown`,()=>{J(),G()})),b&&I.push((0,e.on)(b,`pointerenter`,()=>{J(),G()}),(0,e.on)(b,`transitionend`,e=>{if(e.target!==b)return;let t=C?U.get(C):null;if(t){let e=me(t.item,t.content);Xe(t.content,t.trigger,e)}})),U.forEach(({content:t})=>{I.push((0,e.on)(t,`pointerenter`,()=>{J(),G()}),(0,e.on)(t,`pointerleave`,t=>{if(D)return;let n=t.relatedTarget;Y(n)||(0,e.containsWithPortals)(r,n)||(Q(null),X(null))}))}),I.push((0,e.on)(v,`keydown`,e=>{let t=be(e.target);if(!t)return;let n=W.indexOf(t);if(n===-1)return;let r=n;switch(e.key){case`Tab`:if(e.shiftKey||C===null)return;(we(t,1,{preserveOpenOnPlain:!0})||je())&&e.preventDefault();return;case`ArrowLeft`:r=n-1,r<0&&(r=W.length-1);break;case`ArrowRight`:r=n+1,r>=W.length&&(r=0);break;case`ArrowDown`:if(t.kind===`submenu`){e.preventDefault();let n=t.value;D=!0,Q(n,!0),Me(n)}return;case`Home`:r=0;break;case`End`:r=W.length-1;break;case`Escape`:D=!1,Q(null,!0),X(null);return;default:return}e.preventDefault();let i=W[r];i&&Se(i,{preserveOpenOnPlain:!0})})),U.forEach(({content:t,trigger:n})=>{I.push((0,e.on)(t,`keydown`,e=>{let r=e.target,i=Oe(t),a=i.indexOf(r);if(a!==-1)switch(e.key){case`Tab`:if(!e.shiftKey&&a===i.length-1){(Te(n,1,{preserveOpenOnPlain:!0})||je())&&e.preventDefault();return}if(e.shiftKey&&a===0){e.preventDefault(),n.focus();return}return;case`ArrowDown`:case`ArrowRight`:{e.preventDefault();let t=a+1;t<i.length&&i[t]?.focus();break}case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),a===0?n.focus():i[a-1]?.focus();break;case`Escape`:e.preventDefault(),D=!1,Q(null,!0),X(null),n.focus();break}}))});let $e=()=>(0,e.containsWithPortals)(r,document.activeElement)||A||D,$=()=>{J(),D=!1,Q(null,!0),X(null),Ye()};I.push((0,e.on)(document,`focusin`,t=>{let n=t.target;if(!(0,e.containsWithPortals)(r,n)){if(C!==null){$();return}X(null)}})),I.push((0,e.createDismissLayer)({root:r,isOpen:()=>C!==null&&$e(),onDismiss:$,closeOnClickOutside:!0,closeOnEscape:!0,preventEscapeDefault:!1,isInside:t=>!!t&&(0,e.containsWithPortals)(r,t)})),I.push((0,e.on)(window,`resize`,()=>{C&&requestAnimationFrame(()=>fe()),(C||E)&&requestAnimationFrame(()=>Z(E))}),(0,e.on)(v,`scroll`,()=>{(C||E)&&requestAnimationFrame(()=>Z(E))})),I.push((0,e.on)(r,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)$();else if(U.has(t.value)){D=!0,Q(t.value,!0);let e=U.get(t.value);e&&X(e.trigger)}}}));let et={get value(){return C},open:e=>Q(e,!0),close:()=>Q(null,!0),destroy:()=>{j=!0,G(),I.forEach(e=>e()),I.length=0,(0,e.clearRootBinding)(r,a,et)}};return(0,e.setRootBinding)(r,a,et),et}function s(t=document){let n=[];for(let r of(0,e.getRoots)(t,`navigation-menu`))(0,e.hasRootBinding)(r,a)||n.push(o(r));return n}exports.create=s,exports.createNavigationMenu=o;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=[`start`,`center`,`end`],n=[`top`,`right`,`bottom`,`left`],r=(e,t)=>t===`start`?{x:e.left,y:e.top}:t===`end`?{x:e.right,y:e.bottom}:{x:e.left+e.width/2,y:e.top+e.height/2},i=(e,t,n)=>{let i=r(n,t);return e===`top`?{x:i.x,y:n.top}:e===`bottom`?{x:i.x,y:n.bottom}:e===`left`?{x:n.left,y:i.y}:{x:n.right,y:i.y}},a=`@data-slot/navigation-menu`;function o(r,o={}){let s=(0,e.reuseRootBinding)(r,a,`[@data-slot/navigation-menu] createNavigationMenu() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(s)return s;let c=o.delayOpen??(0,e.getDataNumber)(r,`delayOpen`)??0,l=o.delayClose??(0,e.getDataNumber)(r,`delayClose`)??0,u=o.openOnFocus??(0,e.getDataBool)(r,`openOnFocus`)??!1,d=o.side??(0,e.getDataEnum)(r,`side`,n)??`bottom`,ee=o.align??(0,e.getDataEnum)(r,`align`,t)??`start`,f=o.sideOffset??(0,e.getDataNumber)(r,`sideOffset`)??0,p=o.alignOffset??(0,e.getDataNumber)(r,`alignOffset`)??0,m=o.safeTriangle??(0,e.getDataBool)(r,`safeTriangle`)??!1,h=o.debugSafeTriangle??(0,e.getDataBool)(r,`debugSafeTriangle`)??!1,te=m||h,ne=o.onValueChange,re=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),ie=(e,t)=>{`inert`in e&&(e.inert=t)},g=(0,e.getPart)(r,`navigation-menu-list`),_=(0,e.getParts)(r,`navigation-menu-item`),v=(0,e.getPart)(r,`navigation-menu-viewport`),y=(0,e.getPart)(r,`navigation-menu-indicator`),b=(e,t)=>{let n=e.parentElement;for(;n&&n!==r;){if(n.getAttribute(`data-slot`)===t)return n;n=n.parentElement}return null};if(!g||_.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let x=null,S=null,C=-1,w=null,T=null,E=null,D=!1,O=null,k=null,A=!1,j=!1,M=null,N=null,P=0,F=0,I=[],L=new Map,R=new Map,ae=v?b(v,`navigation-menu-viewport-positioner`):null,oe=v?b(v,`navigation-menu-positioner`):null,z=ae??oe,se=z?b(z,`navigation-menu-portal`):null,B=v?(0,e.createPortalLifecycle)({content:v,root:r,enabled:!0,wrapperSlot:z?void 0:`navigation-menu-viewport-positioner`,container:z??void 0,mountTarget:z?se??z:void 0}):null,ce=()=>{let e=B?.container;e instanceof HTMLElement&&(e.style.position=``,e.style.top=``,e.style.left=``,e.style.width=``,e.style.height=``,e.style.margin=``,e.style.willChange=``,e.style.pointerEvents=``,e.style.transform=``,e.style.removeProperty(`--transform-origin`),e.removeAttribute(`data-instant`))},V=()=>{v?.removeAttribute(`data-instant`);let e=B?.container;e instanceof HTMLElement&&e.removeAttribute(`data-instant`)},le=v?(0,e.createPresenceLifecycle)({element:v,onExitComplete:()=>{j||(V(),ce(),P=0,F=0,B?.restore(),v.hidden=!0,v.style.pointerEvents=`none`)}}):null,ue=e=>{if(!v)return;let t=R.get(e)??{originalParent:null,originalNextSibling:null,mountedInViewport:!1};t.mountedInViewport||(t.originalParent=e.parentNode,t.originalNextSibling=e.nextSibling,t.mountedInViewport=!0,R.set(e,t)),e.parentNode!==v&&v.appendChild(e)},de=e=>{let t=R.get(e);if(!t||!t.mountedInViewport)return;let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.mountedInViewport=!1,t.originalParent=null,t.originalNextSibling=null},fe=()=>{if(!v||!B)return;let e=B.container,t=r.ownerDocument.defaultView??window,n=r.getBoundingClientRect(),i=n.top+t.scrollY+F,a=n.left+t.scrollX+P;e.style.position=`absolute`,e.style.top=`${i}px`,e.style.left=`${a}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.margin=`0`,e.style.willChange=`top,left`,e.style.pointerEvents=`none`},H=null,pe=e=>{H?.disconnect(),H=null,!(!v||!e)&&(H=new ResizeObserver(()=>{let t=me(e.item,e.content);Qe(e.content,e.trigger,t)}),H.observe(e.content))};I.push(()=>H?.disconnect()),I.push(()=>{V(),L.forEach(e=>e.cleanup()),L.clear(),R.forEach((e,t)=>{de(t),t.hidden=!0,t.style.pointerEvents=`none`}),R.clear(),ce(),P=0,F=0,le?.cleanup(),B?.cleanup()});let U=new Map,me=(r,i)=>({side:o.side??(0,e.getDataEnum)(i,`side`,n)??(0,e.getDataEnum)(r,`side`,n)??d,align:o.align??(0,e.getDataEnum)(i,`align`,t)??(0,e.getDataEnum)(r,`align`,t)??ee,sideOffset:o.sideOffset??(0,e.getDataNumber)(i,`sideOffset`)??(0,e.getDataNumber)(r,`sideOffset`)??f,alignOffset:o.alignOffset??(0,e.getDataNumber)(i,`alignOffset`)??(0,e.getDataNumber)(r,`alignOffset`)??p}),he=0;_.forEach(t=>{let n=t.dataset.value;if(!n)return;let r=(0,e.getPart)(t,`navigation-menu-trigger`),i=(0,e.getPart)(t,`navigation-menu-content`);if(r&&i){U.set(n,{value:n,item:t,trigger:r,content:i,index:he++}),L.set(i,(0,e.createPresenceLifecycle)({element:i,onExitComplete:()=>{j||(de(i),i.hidden=!0,i.style.pointerEvents=`none`)}}));let a=re(n),o=(0,e.ensureId)(r,`nav-menu-trigger-${a}`),s=(0,e.ensureId)(i,`nav-menu-content-${a}`);r.setAttribute(`aria-haspopup`,`true`),r.setAttribute(`aria-controls`,s),i.setAttribute(`aria-labelledby`,o)}}),Array.from(U.values()).map(e=>e.trigger);let ge=`a[href], button:not([disabled]), [role="link"], [role="button"], [tabindex]:not([tabindex="-1"])`,_e=e=>{let t=e?.closest(`[data-slot="navigation-menu-item"]`);if(!t)return null;let n=t.dataset.value;if(!n)return null;let r=U.get(n);return!r||r.item!==t?null:r},ve=e=>{if(e.matches(ge))return e;let t=e.querySelectorAll(ge);for(let n of t)if(e.contains(n)&&!n.closest(`[data-slot="navigation-menu-content"]`)&&!(n.hidden||n.closest(`[hidden]`)))return n;return null},W=[],ye=new Map;_.forEach(e=>{let t=_e(e);if(t){let e={kind:`submenu`,element:t.trigger,value:t.value,trigger:t.trigger};W.push(e),ye.set(e.element,e);return}let n=ve(e);if(!n)return;let r={kind:`plain`,element:n};W.push(r),ye.set(r.element,r)});let be=e=>{let t=e instanceof HTMLElement?e:null;if(!t)return null;let n=t;for(;n&&n!==g;){let e=ye.get(n);if(e)return e;n=n.parentElement}return null},xe=e=>{let t=be(e);return t?.kind===`plain`?t:null},Se=(e,t={})=>{let n=r.ownerDocument,i=t.preserveOpenOnPlain??!1;return e.kind===`submenu`?(e.trigger.focus(),n.activeElement===e.trigger?(Z(e.trigger),!0):!1):(x!==null&&!i&&$(),e.element.focus(),n.activeElement===e.element?(x!==null&&i?Z():X(e.element),!0):!1)},Ce=(e,t,n={})=>{for(let r=e+t;r>=0&&r<W.length;r+=t){let e=W[r];if(e&&Se(e,n))return!0}return!1},we=(e,t,n={})=>{let r=W.indexOf(e);return r===-1?!1:Ce(r,t,n)},Te=(e,t,n={})=>{let r=W.findIndex(t=>t.kind===`submenu`&&t.trigger===e);return r===-1?!1:Ce(r,t,n)},Ee=e=>{if(!(e instanceof Node)||!g.contains(e))return!1;let t=e instanceof HTMLElement?e:e.parentElement;return!t||t.closest(`[data-slot="navigation-menu-indicator"]`)||_e(t)?!1:t.closest(`[data-slot="navigation-menu-item"]`)?!0:!!t.closest(`a[href], button, [role='link'], [role='button']`)},De=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,Oe=e=>Array.from(e.querySelectorAll(De)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),ke=e=>!e.isConnected||e.hidden||e.closest(`[hidden]`)||`disabled`in e&&e.disabled||e.getAttribute(`aria-hidden`)===`true`||e.getAttribute(`tabindex`)===`-1`?!1:e.matches(De)?!0:e.tabIndex>=0,Ae=e=>{if(r.contains(e)||v?.contains(e))return!0;let t=B?.container;if(t instanceof HTMLElement&&t.contains(e))return!0;for(let{content:t}of U.values())if(t.contains(e))return!0;return!1},je=()=>{let e=r.ownerDocument,t=Array.from(e.querySelectorAll(`*`));for(let n of t)if(ke(n)&&!Ae(n)&&(r.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0&&(n.focus(),e.activeElement===n))return!0;return!1},Me=e=>{requestAnimationFrame(()=>{if(x!==e)return;let t=U.get(e);if(!t)return;let n=Oe(t.content)[0];n?n.focus():t.content.focus()})},G=()=>{w&&=(clearTimeout(w),null),T&&=(clearTimeout(T),null)},K=()=>{G(),S=null},Ne=()=>{O=null,k=null},Pe=()=>{N!==null&&(cancelAnimationFrame(N),N=null)},q=null,Fe=()=>{if(!v)return null;let e=B?.container;return e instanceof HTMLElement?e:v.parentElement instanceof HTMLElement?v.parentElement:v},Ie=()=>{let t=Fe();return q||(q=document.createElement(`div`),q.setAttribute(`data-slot`,`navigation-menu-bridge`),q.style.cssText=`position: absolute; pointer-events: auto; z-index: 0; display: none;`,I.push((0,e.on)(q,`pointerenter`,()=>{G()}),(0,e.on)(q,`pointerleave`,t=>{if(D||x===null)return;let n=t.relatedTarget;Ze(n)||n&&(0,e.containsWithPortals)(r,n)||(Q(null),X(null))}))),t&&q.parentElement!==t&&t.insertBefore(q,t.firstChild),q},J=()=>{q&&(q.style.height=`0`,q.style.width=`0`,q.style.top=`0px`,q.style.left=`0px`,q.style.right=`0px`,q.style.bottom=`auto`,q.style.transform=`none`,q.style.clipPath=`none`,q.style.display=`none`)},Le=()=>{if(!h)return null;let e=r.ownerDocument.body;return e?(M||(M=r.ownerDocument.createElement(`div`),M.setAttribute(`data-slot`,`navigation-menu-safe-triangle`),M.style.cssText=[`position: fixed`,`pointer-events: none`,`display: none`,`z-index: 2147483647`,`background: rgba(255, 0, 0, 0.18)`,`border: 1px solid rgba(255, 0, 0, 0.45)`].join(`; `)),M.parentElement!==e&&e.appendChild(M),M):null},Re=()=>{M&&(M.style.width=`0`,M.style.height=`0`,M.style.clipPath=`none`,M.style.display=`none`)},Y=()=>{h||Re()},ze=e=>{let t=Le();if(!t)return;let n=e.apex.x,r=e.apex.y,i=e.edgeA.x,a=e.edgeA.y,o=e.edgeB.x,s=e.edgeB.y,c=Math.min(n,i,o),l=Math.min(r,a,s),u=Math.max(n,i,o),d=Math.max(r,a,s),ee=Math.max(1,u-c),f=Math.max(1,d-l),p=(e,t)=>`${(e-c)/ee*100}% ${(t-l)/f*100}%`;t.style.display=`block`,t.style.left=`${c}px`,t.style.top=`${l}px`,t.style.width=`${ee}px`,t.style.height=`${f}px`,t.style.clipPath=`polygon(${p(n,r)}, ${p(i,a)}, ${p(o,s)})`},Be=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),Ve=(e,t,n,r)=>{let i=Be(e,t,n),a=Be(e,n,r),o=Be(e,r,t);return!((i<0||a<0||o<0)&&(i>0||a>0||o>0))},He=(e,t,n)=>{let r=.5;if(n.top>=t.bottom-r)return[{x:n.left,y:n.top},{x:n.right,y:n.top}];if(n.bottom<=t.top+r)return[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}];if(n.left>=t.right-r)return[{x:n.left,y:n.top},{x:n.left,y:n.bottom}];if(n.right<=t.left+r)return[{x:n.right,y:n.top},{x:n.right,y:n.bottom}];let i=[[{x:n.left,y:n.top},{x:n.right,y:n.top}],[{x:n.right,y:n.top},{x:n.right,y:n.bottom}],[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}],[{x:n.left,y:n.top},{x:n.left,y:n.bottom}]],a=([t,n])=>t.y===n.y?Math.abs(e.y-t.y):Math.abs(e.x-t.x),o=i[0],s=a(o);for(let e=1;e<i.length;e++){let t=i[e],n=a(t);n<s&&(o=t,s=n)}return o},Ue=()=>x?U.get(x)??null:null,We=(e,t,n)=>{if(n.width<=0||n.height<=0)return null;let r={x:e.left+e.width/2,y:e.top+e.height*.62},[i,a]=He(r,t,n);if(i.x===a.x){let e=Math.min(i.y,a.y),t=Math.max(i.y,a.y),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:i.x,y:e+r},a={x:a.x,y:t-r}}else{let e=Math.min(i.x,a.x),t=Math.max(i.x,a.x),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:e+r,y:i.y},a={x:t-r,y:a.y}}return{apex:r,edgeA:i,edgeB:a}},Ge=()=>{if(!te||!v||x===null)return null;let e=Ue();if(!e)return null;let t=r.getBoundingClientRect(),n=e.trigger.getBoundingClientRect(),i=v.getBoundingClientRect(),a=e.content.getBoundingClientRect();return We(n,t,i.width>0&&i.height>0?i:a)},Ke=e=>{let t=Ge();return t?Ve({x:e.clientX,y:e.clientY},t.apex,t.edgeA,t.edgeB):!1},qe=(e,t)=>({x:e.x-t.left,y:e.y-t.top}),Je=e=>{if(e.length<=1)return e.slice();let t=e=>`${e.x.toFixed(3)}:${e.y.toFixed(3)}`,n=new Map;for(let r of e)n.set(t(r),r);let r=Array.from(n.values()).sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x);if(r.length<=2)return r;let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=[];for(let e of r){for(;a.length>=2&&i(a[a.length-2],a[a.length-1],e)<=0;)a.pop();a.push(e)}let o=[];for(let e=r.length-1;e>=0;e--){let t=r[e];for(;o.length>=2&&i(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return a.pop(),o.pop(),a.concat(o)},Ye=e=>{if(e.length<3){J();return}let t=Ie(),n=t.parentElement,r=Je(n&&n===B?.container?e.map(e=>({x:e.x-P,y:e.y-F})):e);if(r.length<3){J();return}let i=Math.min(...r.map(e=>e.x)),a=Math.min(...r.map(e=>e.y)),o=Math.max(...r.map(e=>e.x)),s=Math.max(...r.map(e=>e.y)),c=Math.max(1,o-i),l=Math.max(1,s-a),u=e=>`${(e.x-i)/c*100}% ${(e.y-a)/l*100}%`;t.style.display=`block`,t.style.transform=`none`,t.style.bottom=`auto`,t.style.right=`auto`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.width=`${c}px`,t.style.height=`${l}px`,t.style.clipPath=`polygon(${r.map(u).join(`, `)})`},Xe=()=>{if(!h)return;let e=Ge();if(!e){Re();return}ze(e)},Ze=e=>{if(!e)return!1;if(Ue()?.content.contains(e)||v?.contains(e)||q?.contains(e))return!0;let t=B?.container;return!!(t instanceof HTMLElement&&t.contains(e))};I.push(Y),I.push(Pe),I.push(J),I.push(()=>{Re(),M?.parentElement&&M.parentElement.removeChild(M),M=null});let Qe=(t,a,o)=>{v&&requestAnimationFrame(()=>{let s=t.firstElementChild,c=t.lastElementChild,l=s?getComputedStyle(s):null,u=c?getComputedStyle(c):null,d=l&&parseFloat(l.marginTop)||0,ee=u&&parseFloat(u.marginBottom)||0,f=(...e)=>{let t=0;for(let n of e)Number.isFinite(n)&&(t=Math.max(t,n));return t},p=t.getBoundingClientRect(),m=f(p.width,t.scrollWidth,t.offsetWidth,t.clientWidth),h=f(p.height,t.scrollHeight,t.offsetHeight,t.clientHeight)+d+ee,ne={top:p.top,left:p.left,width:m,height:h,right:p.left+m,bottom:p.top+h},re=getComputedStyle(v),ie=parseFloat(re.marginTop)||0;v.style.setProperty(`--viewport-width`,`${m}px`),v.style.setProperty(`--viewport-height`,`${h}px`);let g=r.getBoundingClientRect(),_=a.getBoundingClientRect(),y=(0,e.computeFloatingPosition)({anchorRect:_,contentRect:ne,side:o.side,align:o.align,sideOffset:o.sideOffset,alignOffset:o.alignOffset,avoidCollisions:!1,collisionPadding:0,allowedSides:n}),b=y.x-g.left,x=y.y-g.top;P=b,F=x;let S=i(y.side,y.align,_),C=S.x-(g.left+b),w=S.y-(g.top+x),T=S.x-g.left,E=S.y-g.top,D=`${C}px ${w}px`,O=`${T}px ${E}px`;v.style.top=`0px`,v.style.left=`0px`,v.style.willChange=`transform,width,height`,v.style.setProperty(`--transform-origin`,D),t.style.top=`0px`,t.style.left=`0px`,t.style.setProperty(`--transform-origin`,D),v.setAttribute(`data-side`,y.side),v.setAttribute(`data-align`,y.align),t.setAttribute(`data-side`,y.side),t.setAttribute(`data-align`,y.align);let k=B?.container;k&&k!==v&&(k.setAttribute(`data-side`,y.side),k.setAttribute(`data-align`,y.align),k.style.setProperty(`--transform-origin`,O)),fe();let A=v.getBoundingClientRect(),j=[],M=Math.max(0,A.top-g.bottom),N=Math.max(0,g.top-A.bottom),I=Math.max(0,A.left-g.right),L=Math.max(0,g.left-A.right),R=Math.max(0,d+ie),ae=Math.max(M,N,R),oe=Math.max(I,L),z=te?We(_,g,A):null,se=(e,t,n,r)=>{n<=0||r<=0||j.push({x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r})};if(ae>=oe&&ae>0){let e=Math.max(M,N,R),t=b,n=N>M&&N>=R?x+h:x-e,r=m;if(z){let e=Math.min(z.edgeA.x,z.edgeB.x)-g.left,n=Math.max(z.edgeA.x,z.edgeB.x)-g.left;t=e-8,r=n-e+16}se(t,n,r,e)}else if(oe>0){let e=Math.max(I,L),t=x,n=L>I?b+m:b-e,r=h;if(z){let e=Math.min(z.edgeA.y,z.edgeB.y)-g.top,n=Math.max(z.edgeA.y,z.edgeB.y)-g.top;t=e-8,r=n-e+16}se(n,t,e,r)}if(z){let e=qe(z.apex,g),t=qe(z.edgeA,g),n=qe(z.edgeB,g);j.push(e,t,n)}Ye(j),Xe()})},$e=e=>C===-1||e>C?`right`:`left`,X=e=>{if(!y)return;if(E=e,!e){Pe(),y.removeAttribute(`data-instant`),y.setAttribute(`data-state`,`hidden`);return}y.getAttribute(`data-state`)!==`visible`&&(Pe(),y.setAttribute(`data-instant`,``),N=requestAnimationFrame(()=>{N=requestAnimationFrame(()=>{y.removeAttribute(`data-instant`),N=null})}));let t=g.getBoundingClientRect(),n=e.getBoundingClientRect();y.style.setProperty(`--indicator-left`,`${n.left-t.left}px`),y.style.setProperty(`--indicator-width`,`${n.width}px`),y.style.setProperty(`--indicator-top`,`${n.top-t.top}px`);let r=(v&&parseFloat(getComputedStyle(v).marginTop)||0)<1?1:0;y.style.setProperty(`--indicator-height`,`${n.height-r}px`),y.setAttribute(`data-state`,`visible`)},et=()=>x?U.get(x)?.trigger??null:null,Z=(e=null)=>{let t=et();if(t){X(t);return}X(e)},Q=(t,n=!1)=>{if(Y(),t===x){t===null?K():G();return}if(!n&&t!==null&&t===S)return;G(),S=t===null?null:t;let i=()=>{let n=x,i=t?U.get(t):null,a=n!==null&&t!==null&&n!==t,o=a&&i?$e(i.index):null,s=document.activeElement;if(t===null&&s&&n){let t=U.get(n);t&&(0,e.containsWithPortals)(t.content,s)&&t.trigger.focus()}if(U.forEach(({trigger:r,content:i,item:a},s)=>{let c=s===t,l=s===n;if((0,e.setAria)(r,`expanded`,c),r.setAttribute(`data-state`,c?`open`:`closed`),a.setAttribute(`data-state`,c?`open`:`closed`),!c){let e=L.get(i);if(i.setAttribute(`data-state`,`inactive`),i.setAttribute(`aria-hidden`,`true`),ie(i,!0),i.style.pointerEvents=`none`,l&&o){let e=o===`right`?`to-left`:`to-right`;i.setAttribute(`data-motion`,e)}else l&&i.removeAttribute(`data-motion`);l?e?.exit():e?.isExiting||(i.removeAttribute(`data-motion`),de(i),i.hidden=!0)}}),i){if(B?.mount(),v&&(v.hidden=!1),n===null&&le?.enter(),ue(i.content),L.get(i.content)?.enter(),o){let e=o===`right`?`from-right`:`from-left`;i.content.setAttribute(`data-motion`,e)}else i.content.removeAttribute(`data-motion`);i.content.setAttribute(`data-state`,`active`),i.content.removeAttribute(`aria-hidden`),ie(i.content,!1),i.content.hidden=!1,i.content.style.pointerEvents=`auto`,C=i.index;let e=me(i.item,i.content);Qe(i.content,i.trigger,e),pe(i),X(i.trigger)}else J(),Y(),le?.exit(),pe(null);let c=t!==null;if(r.setAttribute(`data-state`,c?`open`:`closed`),o?r.setAttribute(`data-motion`,o===`right`?`from-right`:`from-left`):r.removeAttribute(`data-motion`),v){v.setAttribute(`data-state`,c?`open`:`closed`),v.style.pointerEvents=c?`auto`:`none`;let e=B?.container;c&&!a?(v.setAttribute(`data-instant`,``),e?.setAttribute(`data-instant`,``)):a?V():c||V(),o&&v.style.setProperty(`--motion-direction`,o===`right`?`1`:`-1`)}x=t,S=null,t===null&&X(null),Xe(),(0,e.emit)(r,`navigation-menu:change`,{value:t}),ne?.(t)};n?i():t!==null&&x===null?w=setTimeout(i,c):t!==null&&x!==null?i():T=setTimeout(i,l)};r.setAttribute(`data-state`,`closed`),v&&(v.setAttribute(`data-state`,`closed`),v.hidden=!0,v.style.pointerEvents=`none`),y&&y.setAttribute(`data-state`,`hidden`),U.forEach(({trigger:t,content:n,item:r})=>{t.tagName===`BUTTON`&&!t.hasAttribute(`type`)&&(t.type=`button`),(0,e.setAria)(t,`expanded`,!1),t.setAttribute(`data-state`,`closed`),t.tabIndex=0,r.setAttribute(`data-state`,`closed`),n.setAttribute(`data-state`,`inactive`),n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1,ie(n,!0),n.hidden=!0,n.style.pointerEvents=`none`}),U.forEach(({item:t,trigger:n},i)=>{I.push((0,e.on)(n,`pointerenter`,e=>{if(!D){if(x!==i&&Ke(e))return;X(n)}})),I.push((0,e.on)(t,`pointerenter`,e=>{if(!D){if(x!==i&&Ke(e))return;Q(i)}})),I.push((0,e.on)(t,`pointerleave`,t=>{if(S===i&&x===null&&K(),x===i&&!D){let n=t.relatedTarget;if(Ze(n))return;(!n||!(0,e.containsWithPortals)(r,n))&&(Q(null),X(null))}})),I.push((0,e.on)(n,`focus`,()=>{if(O===n){O=null;return}u&&Q(i,!0),Z(n)})),I.push((0,e.on)(n,`pointerdown`,()=>{O=n,k=n}),(0,e.on)(n,`keydown`,()=>{k=null})),I.push((0,e.on)(n,`click`,()=>{let e=k===n;k=null,O=null,K(),x===i&&D?(D=!1,Q(null,!0),X(null)):x===i&&!D?(D=!0,X(n),e||Me(i)):(D=!0,Q(i,!0),X(n),e||Me(i))}))}),I.push((0,e.on)(g,`pointerover`,e=>{let t=e;if(t.pointerType===`touch`)return;let n=xe(t.target);if(n){if(x!==null){if(D)return;$()}X(n.element);return}x!==null&&(D||Ee(t.target)&&$())}),(0,e.on)(g,`click`,e=>{x!==null&&Ee(e.target)&&$()})),I.push((0,e.on)(g,`focusin`,e=>{let t=xe(e.target);if(t){if(x!==null){Z();return}X(t.element)}}),(0,e.on)(r,`pointerenter`,()=>{A=!0}),(0,e.on)(r,`pointerleave`,e=>{let t=e.relatedTarget;if(!Ze(t)&&(A=!1,!D)){if(Ke(e)){G();return}Q(null),X(null)}}),(0,e.on)(r,`pointerdown`,()=>{Y(),K()})),v&&I.push((0,e.on)(v,`pointerenter`,()=>{Y(),G()}),(0,e.on)(v,`transitionend`,e=>{if(e.target!==v)return;let t=x?U.get(x):null;if(t){let e=me(t.item,t.content);Qe(t.content,t.trigger,e)}})),U.forEach(({content:t})=>{I.push((0,e.on)(t,`pointerenter`,()=>{Y(),G()}),(0,e.on)(t,`pointerleave`,t=>{if(D)return;let n=t.relatedTarget;Ze(n)||(0,e.containsWithPortals)(r,n)||(Q(null),X(null))}))}),I.push((0,e.on)(g,`keydown`,e=>{let t=be(e.target);if(!t)return;let n=W.indexOf(t);if(n===-1)return;let r=n;switch(e.key){case`Tab`:if(e.shiftKey||x===null)return;(we(t,1,{preserveOpenOnPlain:!0})||je())&&e.preventDefault();return;case`ArrowLeft`:r=n-1,r<0&&(r=W.length-1);break;case`ArrowRight`:r=n+1,r>=W.length&&(r=0);break;case`ArrowDown`:if(t.kind===`submenu`){e.preventDefault();let n=t.value;D=!0,Q(n,!0),Me(n)}return;case`Home`:r=0;break;case`End`:r=W.length-1;break;case`Escape`:D=!1,Q(null,!0),X(null);return;default:return}e.preventDefault();let i=W[r];i&&Se(i,{preserveOpenOnPlain:!0})})),U.forEach(({content:t,trigger:n})=>{I.push((0,e.on)(t,`keydown`,e=>{let r=e.target,i=Oe(t),a=i.indexOf(r);if(a!==-1)switch(e.key){case`Tab`:if(!e.shiftKey&&a===i.length-1){(Te(n,1,{preserveOpenOnPlain:!0})||je())&&e.preventDefault();return}if(e.shiftKey&&a===0){e.preventDefault(),n.focus();return}return;case`ArrowDown`:case`ArrowRight`:{e.preventDefault();let t=a+1;t<i.length&&i[t]?.focus();break}case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),a===0?n.focus():i[a-1]?.focus();break;case`Escape`:e.preventDefault(),D=!1,Q(null,!0),X(null),n.focus();break}}))});let tt=()=>(0,e.containsWithPortals)(r,document.activeElement)||A||D,$=()=>{Y(),K(),Ne(),D=!1,Q(null,!0),X(null),Xe()};I.push((0,e.on)(document,`focusin`,t=>{let n=t.target;if(!(0,e.containsWithPortals)(r,n)){if(x!==null){$();return}X(null)}})),I.push((0,e.createDismissLayer)({root:r,isOpen:()=>x!==null&&tt(),onDismiss:$,closeOnClickOutside:!0,closeOnEscape:!0,preventEscapeDefault:!1,isInside:t=>!!t&&(0,e.containsWithPortals)(r,t)})),I.push((0,e.on)(window,`resize`,()=>{x&&requestAnimationFrame(()=>fe()),(x||E)&&requestAnimationFrame(()=>Z(E))}),(0,e.on)(g,`scroll`,()=>{(x||E)&&requestAnimationFrame(()=>Z(E))})),I.push((0,e.on)(r,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)$();else if(U.has(t.value)){D=!0,Q(t.value,!0);let e=U.get(t.value);e&&X(e.trigger)}}}));let nt={get value(){return x},open:e=>Q(e,!0),close:()=>$(),destroy:()=>{j=!0,K(),Ne(),I.forEach(e=>e()),I.length=0,(0,e.clearRootBinding)(r,a,nt)}};return(0,e.setRootBinding)(r,a,nt),nt}function s(t=document){let n=[];for(let r of(0,e.getRoots)(t,`navigation-menu`))(0,e.hasRootBinding)(r,a)||n.push(o(r));return n}exports.create=s,exports.createNavigationMenu=o;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clearRootBinding as e,computeFloatingPosition as t,containsWithPortals as n,createDismissLayer as r,createPortalLifecycle as i,createPresenceLifecycle as a,emit as o,ensureId as s,getDataBool as c,getDataEnum as l,getDataNumber as u,getPart as d,getParts as f,getRoots as p,hasRootBinding as m,on as h,reuseRootBinding as ee,setAria as te,setRootBinding as g}from"@data-slot/core";const _=[`start`,`center`,`end`],ne=[`top`,`right`,`bottom`,`left`],v=(e,t)=>t===`start`?{x:e.left,y:e.top}:t===`end`?{x:e.right,y:e.bottom}:{x:e.left+e.width/2,y:e.top+e.height/2},re=(e,t,n)=>{let r=v(n,t);return e===`top`?{x:r.x,y:n.top}:e===`bottom`?{x:r.x,y:n.bottom}:e===`left`?{x:n.left,y:r.y}:{x:n.right,y:r.y}},y=`@data-slot/navigation-menu`;function b(p,m={}){let v=ee(p,y,`[@data-slot/navigation-menu] createNavigationMenu() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(v)return v;let b=m.delayOpen??u(p,`delayOpen`)??0,x=m.delayClose??u(p,`delayClose`)??0,ie=m.openOnFocus??c(p,`openOnFocus`)??!1,ae=m.side??l(p,`side`,ne)??`bottom`,oe=m.align??l(p,`align`,_)??`start`,se=m.sideOffset??u(p,`sideOffset`)??0,ce=m.alignOffset??u(p,`alignOffset`)??0,le=m.safeTriangle??c(p,`safeTriangle`)??!1,S=m.debugSafeTriangle??c(p,`debugSafeTriangle`)??!1,ue=le||S,C=m.onValueChange,de=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),w=(e,t)=>{`inert`in e&&(e.inert=t)},T=d(p,`navigation-menu-list`),E=f(p,`navigation-menu-item`),D=d(p,`navigation-menu-viewport`),O=d(p,`navigation-menu-indicator`),k=(e,t)=>{let n=e.parentElement;for(;n&&n!==p;){if(n.getAttribute(`data-slot`)===t)return n;n=n.parentElement}return null};if(!T||E.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let A=null,j=null,M=-1,N=null,fe=null,P=null,F=!1,pe=null,me=null,he=!1,ge=!1,I=null,L=null,R=0,z=0,B=[],V=new Map,H=new Map,_e=D?k(D,`navigation-menu-viewport-positioner`):null,ve=D?k(D,`navigation-menu-positioner`):null,U=_e??ve,ye=U?k(U,`navigation-menu-portal`):null,W=D?i({content:D,root:p,enabled:!0,wrapperSlot:U?void 0:`navigation-menu-viewport-positioner`,container:U??void 0,mountTarget:U?ye??U:void 0}):null,be=()=>{let e=W?.container;e instanceof HTMLElement&&(e.style.position=``,e.style.top=``,e.style.left=``,e.style.width=``,e.style.height=``,e.style.margin=``,e.style.willChange=``,e.style.pointerEvents=``,e.style.transform=``,e.style.removeProperty(`--transform-origin`),e.removeAttribute(`data-instant`))},xe=()=>{D?.removeAttribute(`data-instant`);let e=W?.container;e instanceof HTMLElement&&e.removeAttribute(`data-instant`)},Se=D?a({element:D,onExitComplete:()=>{ge||(xe(),be(),R=0,z=0,W?.restore(),D.hidden=!0,D.style.pointerEvents=`none`)}}):null,Ce=e=>{if(!D)return;let t=H.get(e)??{originalParent:null,originalNextSibling:null,mountedInViewport:!1};t.mountedInViewport||(t.originalParent=e.parentNode,t.originalNextSibling=e.nextSibling,t.mountedInViewport=!0,H.set(e,t)),e.parentNode!==D&&D.appendChild(e)},we=e=>{let t=H.get(e);if(!t||!t.mountedInViewport)return;let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.mountedInViewport=!1,t.originalParent=null,t.originalNextSibling=null},Te=()=>{if(!D||!W)return;let e=W.container,t=p.ownerDocument.defaultView??window,n=p.getBoundingClientRect(),r=n.top+t.scrollY+z,i=n.left+t.scrollX+R;e.style.position=`absolute`,e.style.top=`${r}px`,e.style.left=`${i}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.margin=`0`,e.style.willChange=`top,left`,e.style.pointerEvents=`none`},Ee=null,De=e=>{Ee?.disconnect(),Ee=null,!(!D||!e)&&(Ee=new ResizeObserver(()=>{let t=Oe(e.item,e.content);ft(e.content,e.trigger,t)}),Ee.observe(e.content))};B.push(()=>Ee?.disconnect()),B.push(()=>{xe(),V.forEach(e=>e.cleanup()),V.clear(),H.forEach((e,t)=>{we(t),t.hidden=!0,t.style.pointerEvents=`none`}),H.clear(),be(),R=0,z=0,Se?.cleanup(),W?.cleanup()});let G=new Map,Oe=(e,t)=>({side:m.side??l(t,`side`,ne)??l(e,`side`,ne)??ae,align:m.align??l(t,`align`,_)??l(e,`align`,_)??oe,sideOffset:m.sideOffset??u(t,`sideOffset`)??u(e,`sideOffset`)??se,alignOffset:m.alignOffset??u(t,`alignOffset`)??u(e,`alignOffset`)??ce}),ke=0;E.forEach(e=>{let t=e.dataset.value;if(!t)return;let n=d(e,`navigation-menu-trigger`),r=d(e,`navigation-menu-content`);if(n&&r){G.set(t,{value:t,item:e,trigger:n,content:r,index:ke++}),V.set(r,a({element:r,onExitComplete:()=>{ge||(we(r),r.hidden=!0,r.style.pointerEvents=`none`)}}));let i=de(t),o=s(n,`nav-menu-trigger-${i}`),c=s(r,`nav-menu-content-${i}`);n.setAttribute(`aria-haspopup`,`true`),n.setAttribute(`aria-controls`,c),r.setAttribute(`aria-labelledby`,o)}}),Array.from(G.values()).map(e=>e.trigger);let Ae=`a[href], button:not([disabled]), [role="link"], [role="button"], [tabindex]:not([tabindex="-1"])`,je=e=>{let t=e?.closest(`[data-slot="navigation-menu-item"]`);if(!t)return null;let n=t.dataset.value;if(!n)return null;let r=G.get(n);return!r||r.item!==t?null:r},Me=e=>{if(e.matches(Ae))return e;let t=e.querySelectorAll(Ae);for(let n of t)if(e.contains(n)&&!n.closest(`[data-slot="navigation-menu-content"]`)&&!(n.hidden||n.closest(`[hidden]`)))return n;return null},K=[],Ne=new Map;E.forEach(e=>{let t=je(e);if(t){let e={kind:`submenu`,element:t.trigger,value:t.value,trigger:t.trigger};K.push(e),Ne.set(e.element,e);return}let n=Me(e);if(!n)return;let r={kind:`plain`,element:n};K.push(r),Ne.set(r.element,r)});let Pe=e=>{let t=e instanceof HTMLElement?e:null;if(!t)return null;let n=t;for(;n&&n!==T;){let e=Ne.get(n);if(e)return e;n=n.parentElement}return null},Fe=e=>{let t=Pe(e);return t?.kind===`plain`?t:null},Ie=(e,t={})=>{let n=p.ownerDocument,r=t.preserveOpenOnPlain??!1;return e.kind===`submenu`?(e.trigger.focus(),n.activeElement===e.trigger?(Z(e.trigger),!0):!1):(A!==null&&!r&&$(),e.element.focus(),n.activeElement===e.element?(A!==null&&r?Z():X(e.element),!0):!1)},Le=(e,t,n={})=>{for(let r=e+t;r>=0&&r<K.length;r+=t){let e=K[r];if(e&&Ie(e,n))return!0}return!1},Re=(e,t,n={})=>{let r=K.indexOf(e);return r===-1?!1:Le(r,t,n)},ze=(e,t,n={})=>{let r=K.findIndex(t=>t.kind===`submenu`&&t.trigger===e);return r===-1?!1:Le(r,t,n)},Be=e=>{if(!(e instanceof Node)||!T.contains(e))return!1;let t=e instanceof HTMLElement?e:e.parentElement;return!t||t.closest(`[data-slot="navigation-menu-indicator"]`)||je(t)?!1:t.closest(`[data-slot="navigation-menu-item"]`)?!0:!!t.closest(`a[href], button, [role='link'], [role='button']`)},Ve=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,He=e=>Array.from(e.querySelectorAll(Ve)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),Ue=e=>!e.isConnected||e.hidden||e.closest(`[hidden]`)||`disabled`in e&&e.disabled||e.getAttribute(`aria-hidden`)===`true`||e.getAttribute(`tabindex`)===`-1`?!1:e.matches(Ve)?!0:e.tabIndex>=0,We=e=>{if(p.contains(e)||D?.contains(e))return!0;let t=W?.container;if(t instanceof HTMLElement&&t.contains(e))return!0;for(let{content:t}of G.values())if(t.contains(e))return!0;return!1},Ge=()=>{let e=p.ownerDocument,t=Array.from(e.querySelectorAll(`*`));for(let n of t)if(Ue(n)&&!We(n)&&(p.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0&&(n.focus(),e.activeElement===n))return!0;return!1},Ke=e=>{requestAnimationFrame(()=>{if(A!==e)return;let t=G.get(e);if(!t)return;let n=He(t.content)[0];n?n.focus():t.content.focus()})},q=()=>{N&&=(clearTimeout(N),null),fe&&=(clearTimeout(fe),null)},qe=()=>{L!==null&&(cancelAnimationFrame(L),L=null)},J=null,Je=()=>{if(!D)return null;let e=W?.container;return e instanceof HTMLElement?e:D.parentElement instanceof HTMLElement?D.parentElement:D},Ye=()=>{let e=Je();return J||(J=document.createElement(`div`),J.setAttribute(`data-slot`,`navigation-menu-bridge`),J.style.cssText=`position: absolute; pointer-events: auto; z-index: 0; display: none;`,B.push(h(J,`pointerenter`,()=>{q()}),h(J,`pointerleave`,e=>{if(F||A===null)return;let t=e.relatedTarget;dt(t)||t&&n(p,t)||(Q(null),X(null))}))),e&&J.parentElement!==e&&e.insertBefore(J,e.firstChild),J},Xe=()=>{J&&(J.style.height=`0`,J.style.width=`0`,J.style.top=`0px`,J.style.left=`0px`,J.style.right=`0px`,J.style.bottom=`auto`,J.style.transform=`none`,J.style.clipPath=`none`,J.style.display=`none`)},Ze=()=>{if(!S)return null;let e=p.ownerDocument.body;return e?(I||(I=p.ownerDocument.createElement(`div`),I.setAttribute(`data-slot`,`navigation-menu-safe-triangle`),I.style.cssText=[`position: fixed`,`pointer-events: none`,`display: none`,`z-index: 2147483647`,`background: rgba(255, 0, 0, 0.18)`,`border: 1px solid rgba(255, 0, 0, 0.45)`].join(`; `)),I.parentElement!==e&&e.appendChild(I),I):null},Qe=()=>{I&&(I.style.width=`0`,I.style.height=`0`,I.style.clipPath=`none`,I.style.display=`none`)},Y=()=>{S||Qe()},$e=e=>{let t=Ze();if(!t)return;let n=e.apex.x,r=e.apex.y,i=e.edgeA.x,a=e.edgeA.y,o=e.edgeB.x,s=e.edgeB.y,c=Math.min(n,i,o),l=Math.min(r,a,s),u=Math.max(n,i,o),d=Math.max(r,a,s),f=Math.max(1,u-c),p=Math.max(1,d-l),m=(e,t)=>`${(e-c)/f*100}% ${(t-l)/p*100}%`;t.style.display=`block`,t.style.left=`${c}px`,t.style.top=`${l}px`,t.style.width=`${f}px`,t.style.height=`${p}px`,t.style.clipPath=`polygon(${m(n,r)}, ${m(i,a)}, ${m(o,s)})`},et=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),tt=(e,t,n,r)=>{let i=et(e,t,n),a=et(e,n,r),o=et(e,r,t);return!((i<0||a<0||o<0)&&(i>0||a>0||o>0))},nt=(e,t,n)=>{let r=.5;if(n.top>=t.bottom-r)return[{x:n.left,y:n.top},{x:n.right,y:n.top}];if(n.bottom<=t.top+r)return[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}];if(n.left>=t.right-r)return[{x:n.left,y:n.top},{x:n.left,y:n.bottom}];if(n.right<=t.left+r)return[{x:n.right,y:n.top},{x:n.right,y:n.bottom}];let i=[[{x:n.left,y:n.top},{x:n.right,y:n.top}],[{x:n.right,y:n.top},{x:n.right,y:n.bottom}],[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}],[{x:n.left,y:n.top},{x:n.left,y:n.bottom}]],a=([t,n])=>t.y===n.y?Math.abs(e.y-t.y):Math.abs(e.x-t.x),o=i[0],s=a(o);for(let e=1;e<i.length;e++){let t=i[e],n=a(t);n<s&&(o=t,s=n)}return o},rt=()=>A?G.get(A)??null:null,it=(e,t,n)=>{if(n.width<=0||n.height<=0)return null;let r={x:e.left+e.width/2,y:e.top+e.height*.62},[i,a]=nt(r,t,n);if(i.x===a.x){let e=Math.min(i.y,a.y),t=Math.max(i.y,a.y),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:i.x,y:e+r},a={x:a.x,y:t-r}}else{let e=Math.min(i.x,a.x),t=Math.max(i.x,a.x),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:e+r,y:i.y},a={x:t-r,y:a.y}}return{apex:r,edgeA:i,edgeB:a}},at=()=>{if(!ue||!D||A===null)return null;let e=rt();if(!e)return null;let t=p.getBoundingClientRect(),n=e.trigger.getBoundingClientRect(),r=D.getBoundingClientRect(),i=e.content.getBoundingClientRect();return it(n,t,r.width>0&&r.height>0?r:i)},ot=e=>{let t=at();return t?tt({x:e.clientX,y:e.clientY},t.apex,t.edgeA,t.edgeB):!1},st=(e,t)=>({x:e.x-t.left,y:e.y-t.top}),ct=e=>{if(e.length<=1)return e.slice();let t=e=>`${e.x.toFixed(3)}:${e.y.toFixed(3)}`,n=new Map;for(let r of e)n.set(t(r),r);let r=Array.from(n.values()).sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x);if(r.length<=2)return r;let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=[];for(let e of r){for(;a.length>=2&&i(a[a.length-2],a[a.length-1],e)<=0;)a.pop();a.push(e)}let o=[];for(let e=r.length-1;e>=0;e--){let t=r[e];for(;o.length>=2&&i(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return a.pop(),o.pop(),a.concat(o)},lt=e=>{if(e.length<3){Xe();return}let t=Ye(),n=t.parentElement,r=ct(n&&n===W?.container?e.map(e=>({x:e.x-R,y:e.y-z})):e);if(r.length<3){Xe();return}let i=Math.min(...r.map(e=>e.x)),a=Math.min(...r.map(e=>e.y)),o=Math.max(...r.map(e=>e.x)),s=Math.max(...r.map(e=>e.y)),c=Math.max(1,o-i),l=Math.max(1,s-a),u=e=>`${(e.x-i)/c*100}% ${(e.y-a)/l*100}%`;t.style.display=`block`,t.style.transform=`none`,t.style.bottom=`auto`,t.style.right=`auto`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.width=`${c}px`,t.style.height=`${l}px`,t.style.clipPath=`polygon(${r.map(u).join(`, `)})`},ut=()=>{if(!S)return;let e=at();if(!e){Qe();return}$e(e)},dt=e=>{if(!e)return!1;if(rt()?.content.contains(e)||D?.contains(e)||J?.contains(e))return!0;let t=W?.container;return!!(t instanceof HTMLElement&&t.contains(e))};B.push(Y),B.push(qe),B.push(Xe),B.push(()=>{Qe(),I?.parentElement&&I.parentElement.removeChild(I),I=null});let ft=(e,n,r)=>{D&&requestAnimationFrame(()=>{let i=e.firstElementChild,a=e.lastElementChild,o=i?getComputedStyle(i):null,s=a?getComputedStyle(a):null,c=o&&parseFloat(o.marginTop)||0,l=s&&parseFloat(s.marginBottom)||0,u=(...e)=>{let t=0;for(let n of e)Number.isFinite(n)&&(t=Math.max(t,n));return t},d=e.getBoundingClientRect(),f=u(d.width,e.scrollWidth,e.offsetWidth,e.clientWidth),m=u(d.height,e.scrollHeight,e.offsetHeight,e.clientHeight)+c+l,h={top:d.top,left:d.left,width:f,height:m,right:d.left+f,bottom:d.top+m},ee=getComputedStyle(D),te=parseFloat(ee.marginTop)||0;D.style.setProperty(`--viewport-width`,`${f}px`),D.style.setProperty(`--viewport-height`,`${m}px`);let g=p.getBoundingClientRect(),_=n.getBoundingClientRect(),v=t({anchorRect:_,contentRect:h,side:r.side,align:r.align,sideOffset:r.sideOffset,alignOffset:r.alignOffset,avoidCollisions:!1,collisionPadding:0,allowedSides:ne}),y=v.x-g.left,b=v.y-g.top;R=y,z=b;let x=re(v.side,v.align,_),ie=x.x-(g.left+y),ae=x.y-(g.top+b),oe=x.x-g.left,se=x.y-g.top,ce=`${ie}px ${ae}px`,le=`${oe}px ${se}px`;D.style.top=`0px`,D.style.left=`0px`,D.style.willChange=`transform,width,height`,D.style.setProperty(`--transform-origin`,ce),e.style.top=`0px`,e.style.left=`0px`,e.style.setProperty(`--transform-origin`,ce),D.setAttribute(`data-side`,v.side),D.setAttribute(`data-align`,v.align),e.setAttribute(`data-side`,v.side),e.setAttribute(`data-align`,v.align);let S=W?.container;S&&S!==D&&(S.setAttribute(`data-side`,v.side),S.setAttribute(`data-align`,v.align),S.style.setProperty(`--transform-origin`,le)),Te();let C=D.getBoundingClientRect(),de=[],w=Math.max(0,C.top-g.bottom),T=Math.max(0,g.top-C.bottom),E=Math.max(0,C.left-g.right),O=Math.max(0,g.left-C.right),k=Math.max(0,c+te),A=Math.max(w,T,k),j=Math.max(E,O),M=ue?it(_,g,C):null,N=(e,t,n,r)=>{n<=0||r<=0||de.push({x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r})};if(A>=j&&A>0){let e=Math.max(w,T,k),t=y,n=T>w&&T>=k?b+m:b-e,r=f;if(M){let e=Math.min(M.edgeA.x,M.edgeB.x)-g.left,n=Math.max(M.edgeA.x,M.edgeB.x)-g.left;t=e-8,r=n-e+16}N(t,n,r,e)}else if(j>0){let e=Math.max(E,O),t=b,n=O>E?y+f:y-e,r=m;if(M){let e=Math.min(M.edgeA.y,M.edgeB.y)-g.top,n=Math.max(M.edgeA.y,M.edgeB.y)-g.top;t=e-8,r=n-e+16}N(n,t,e,r)}if(M){let e=st(M.apex,g),t=st(M.edgeA,g),n=st(M.edgeB,g);de.push(e,t,n)}lt(de),ut()})},pt=e=>M===-1||e>M?`right`:`left`,X=e=>{if(!O)return;if(P=e,!e){qe(),O.removeAttribute(`data-instant`),O.setAttribute(`data-state`,`hidden`);return}O.getAttribute(`data-state`)!==`visible`&&(qe(),O.setAttribute(`data-instant`,``),L=requestAnimationFrame(()=>{L=requestAnimationFrame(()=>{O.removeAttribute(`data-instant`),L=null})}));let t=T.getBoundingClientRect(),n=e.getBoundingClientRect();O.style.setProperty(`--indicator-left`,`${n.left-t.left}px`),O.style.setProperty(`--indicator-width`,`${n.width}px`),O.style.setProperty(`--indicator-top`,`${n.top-t.top}px`);let r=(D&&parseFloat(getComputedStyle(D).marginTop)||0)<1?1:0;O.style.setProperty(`--indicator-height`,`${n.height-r}px`),O.setAttribute(`data-state`,`visible`)},mt=()=>A?G.get(A)?.trigger??null:null,Z=(e=null)=>{let t=mt();if(t){X(t);return}X(e)},Q=(e,t=!1)=>{if(Y(),e===A){q();return}if(e!==null&&e===j){q();return}q(),j=e===null?null:e;let r=()=>{let t=A,r=e?G.get(e):null,i=t!==null&&e!==null&&t!==e,a=i&&r?pt(r.index):null,s=document.activeElement;if(e===null&&s&&t){let e=G.get(t);e&&n(e.content,s)&&e.trigger.focus()}if(G.forEach(({trigger:n,content:r,item:i},o)=>{let s=o===e,c=o===t;if(te(n,`expanded`,s),n.setAttribute(`data-state`,s?`open`:`closed`),i.setAttribute(`data-state`,s?`open`:`closed`),!s){let e=V.get(r);if(r.setAttribute(`data-state`,`inactive`),r.setAttribute(`aria-hidden`,`true`),w(r,!0),r.style.pointerEvents=`none`,c&&a){let e=a===`right`?`to-left`:`to-right`;r.setAttribute(`data-motion`,e)}else c&&r.removeAttribute(`data-motion`);c?e?.exit():e?.isExiting||(r.removeAttribute(`data-motion`),we(r),r.hidden=!0)}}),r){if(W?.mount(),D&&(D.hidden=!1),t===null&&Se?.enter(),Ce(r.content),V.get(r.content)?.enter(),a){let e=a===`right`?`from-right`:`from-left`;r.content.setAttribute(`data-motion`,e)}else r.content.removeAttribute(`data-motion`);r.content.setAttribute(`data-state`,`active`),r.content.removeAttribute(`aria-hidden`),w(r.content,!1),r.content.hidden=!1,r.content.style.pointerEvents=`auto`,M=r.index;let e=Oe(r.item,r.content);ft(r.content,r.trigger,e),De(r),X(r.trigger)}else Xe(),Y(),Se?.exit(),De(null);let c=e!==null;if(p.setAttribute(`data-state`,c?`open`:`closed`),a?p.setAttribute(`data-motion`,a===`right`?`from-right`:`from-left`):p.removeAttribute(`data-motion`),D){D.setAttribute(`data-state`,c?`open`:`closed`),D.style.pointerEvents=c?`auto`:`none`;let e=W?.container;c&&!i?(D.setAttribute(`data-instant`,``),e?.setAttribute(`data-instant`,``)):i?xe():c||xe(),a&&D.style.setProperty(`--motion-direction`,a===`right`?`1`:`-1`)}A=e,j=null,e===null&&X(null),ut(),o(p,`navigation-menu:change`,{value:e}),C?.(e)};t?r():e!==null&&A===null?N=setTimeout(r,b):e!==null&&A!==null?r():fe=setTimeout(r,x)};p.setAttribute(`data-state`,`closed`),D&&(D.setAttribute(`data-state`,`closed`),D.hidden=!0,D.style.pointerEvents=`none`),O&&O.setAttribute(`data-state`,`hidden`),G.forEach(({trigger:e,content:t,item:n})=>{e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&(e.type=`button`),te(e,`expanded`,!1),e.setAttribute(`data-state`,`closed`),e.tabIndex=0,n.setAttribute(`data-state`,`closed`),t.setAttribute(`data-state`,`inactive`),t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,w(t,!0),t.hidden=!0,t.style.pointerEvents=`none`}),G.forEach(({item:e,trigger:t},r)=>{B.push(h(t,`pointerenter`,e=>{if(!F){if(A!==r&&ot(e))return;X(t)}})),B.push(h(e,`pointerenter`,e=>{if(!F){if(A!==r&&ot(e))return;Q(r)}})),B.push(h(e,`pointerleave`,e=>{if(j===r&&A===null&&(q(),j=null),A===r&&!F){let t=e.relatedTarget;if(dt(t))return;(!t||!n(p,t))&&(Q(null),X(null))}})),B.push(h(t,`focus`,()=>{if(pe===t){pe=null;return}ie&&Q(r,!0),Z(t)})),B.push(h(t,`pointerdown`,()=>{pe=t,me=t}),h(t,`keydown`,()=>{me=null})),B.push(h(t,`click`,()=>{let e=me===t;me=null,pe=null,q(),A===r&&F?(F=!1,Q(null,!0),X(null)):A===r&&!F?(F=!0,X(t),e||Ke(r)):(F=!0,Q(r,!0),X(t),e||Ke(r))}))}),B.push(h(T,`pointerover`,e=>{let t=e;if(t.pointerType===`touch`)return;let n=Fe(t.target);if(n){if(A!==null){if(F)return;$()}X(n.element);return}A!==null&&(F||Be(t.target)&&$())}),h(T,`click`,e=>{A!==null&&Be(e.target)&&$()})),B.push(h(T,`focusin`,e=>{let t=Fe(e.target);if(t){if(A!==null){Z();return}X(t.element)}}),h(p,`pointerenter`,()=>{he=!0}),h(p,`pointerleave`,e=>{let t=e.relatedTarget;if(!dt(t)&&(he=!1,!F)){if(ot(e)){q();return}Q(null),X(null)}}),h(p,`pointerdown`,()=>{Y(),q()})),D&&B.push(h(D,`pointerenter`,()=>{Y(),q()}),h(D,`transitionend`,e=>{if(e.target!==D)return;let t=A?G.get(A):null;if(t){let e=Oe(t.item,t.content);ft(t.content,t.trigger,e)}})),G.forEach(({content:e})=>{B.push(h(e,`pointerenter`,()=>{Y(),q()}),h(e,`pointerleave`,e=>{if(F)return;let t=e.relatedTarget;dt(t)||n(p,t)||(Q(null),X(null))}))}),B.push(h(T,`keydown`,e=>{let t=Pe(e.target);if(!t)return;let n=K.indexOf(t);if(n===-1)return;let r=n;switch(e.key){case`Tab`:if(e.shiftKey||A===null)return;(Re(t,1,{preserveOpenOnPlain:!0})||Ge())&&e.preventDefault();return;case`ArrowLeft`:r=n-1,r<0&&(r=K.length-1);break;case`ArrowRight`:r=n+1,r>=K.length&&(r=0);break;case`ArrowDown`:if(t.kind===`submenu`){e.preventDefault();let n=t.value;F=!0,Q(n,!0),Ke(n)}return;case`Home`:r=0;break;case`End`:r=K.length-1;break;case`Escape`:F=!1,Q(null,!0),X(null);return;default:return}e.preventDefault();let i=K[r];i&&Ie(i,{preserveOpenOnPlain:!0})})),G.forEach(({content:e,trigger:t})=>{B.push(h(e,`keydown`,n=>{let r=n.target,i=He(e),a=i.indexOf(r);if(a!==-1)switch(n.key){case`Tab`:if(!n.shiftKey&&a===i.length-1){(ze(t,1,{preserveOpenOnPlain:!0})||Ge())&&n.preventDefault();return}if(n.shiftKey&&a===0){n.preventDefault(),t.focus();return}return;case`ArrowDown`:case`ArrowRight`:{n.preventDefault();let e=a+1;e<i.length&&i[e]?.focus();break}case`ArrowUp`:case`ArrowLeft`:n.preventDefault(),a===0?t.focus():i[a-1]?.focus();break;case`Escape`:n.preventDefault(),F=!1,Q(null,!0),X(null),t.focus();break}}))});let ht=()=>n(p,document.activeElement)||he||F,$=()=>{Y(),F=!1,Q(null,!0),X(null),ut()};B.push(h(document,`focusin`,e=>{let t=e.target;if(!n(p,t)){if(A!==null){$();return}X(null)}})),B.push(r({root:p,isOpen:()=>A!==null&&ht(),onDismiss:$,closeOnClickOutside:!0,closeOnEscape:!0,preventEscapeDefault:!1,isInside:e=>!!e&&n(p,e)})),B.push(h(window,`resize`,()=>{A&&requestAnimationFrame(()=>Te()),(A||P)&&requestAnimationFrame(()=>Z(P))}),h(T,`scroll`,()=>{(A||P)&&requestAnimationFrame(()=>Z(P))})),B.push(h(p,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)$();else if(G.has(t.value)){F=!0,Q(t.value,!0);let e=G.get(t.value);e&&X(e.trigger)}}}));let gt={get value(){return A},open:e=>Q(e,!0),close:()=>Q(null,!0),destroy:()=>{ge=!0,q(),B.forEach(e=>e()),B.length=0,e(p,y,gt)}};return g(p,y,gt),gt}function x(e=document){let t=[];for(let n of p(e,`navigation-menu`))m(n,y)||t.push(b(n));return t}export{x as create,b as createNavigationMenu};
|
|
1
|
+
import{clearRootBinding as e,computeFloatingPosition as t,containsWithPortals as n,createDismissLayer as r,createPortalLifecycle as i,createPresenceLifecycle as a,emit as o,ensureId as s,getDataBool as c,getDataEnum as l,getDataNumber as u,getPart as d,getParts as f,getRoots as p,hasRootBinding as m,on as h,reuseRootBinding as ee,setAria as te,setRootBinding as g}from"@data-slot/core";const _=[`start`,`center`,`end`],ne=[`top`,`right`,`bottom`,`left`],v=(e,t)=>t===`start`?{x:e.left,y:e.top}:t===`end`?{x:e.right,y:e.bottom}:{x:e.left+e.width/2,y:e.top+e.height/2},re=(e,t,n)=>{let r=v(n,t);return e===`top`?{x:r.x,y:n.top}:e===`bottom`?{x:r.x,y:n.bottom}:e===`left`?{x:n.left,y:r.y}:{x:n.right,y:r.y}},y=`@data-slot/navigation-menu`;function b(p,m={}){let v=ee(p,y,`[@data-slot/navigation-menu] createNavigationMenu() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(v)return v;let b=m.delayOpen??u(p,`delayOpen`)??0,x=m.delayClose??u(p,`delayClose`)??0,ie=m.openOnFocus??c(p,`openOnFocus`)??!1,ae=m.side??l(p,`side`,ne)??`bottom`,oe=m.align??l(p,`align`,_)??`start`,se=m.sideOffset??u(p,`sideOffset`)??0,ce=m.alignOffset??u(p,`alignOffset`)??0,le=m.safeTriangle??c(p,`safeTriangle`)??!1,S=m.debugSafeTriangle??c(p,`debugSafeTriangle`)??!1,ue=le||S,C=m.onValueChange,de=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),w=(e,t)=>{`inert`in e&&(e.inert=t)},T=d(p,`navigation-menu-list`),E=f(p,`navigation-menu-item`),D=d(p,`navigation-menu-viewport`),O=d(p,`navigation-menu-indicator`),k=(e,t)=>{let n=e.parentElement;for(;n&&n!==p;){if(n.getAttribute(`data-slot`)===t)return n;n=n.parentElement}return null};if(!T||E.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let A=null,j=null,M=-1,N=null,fe=null,P=null,F=!1,I=null,L=null,pe=!1,me=!1,R=null,z=null,B=0,he=0,V=[],ge=new Map,_e=new Map,ve=D?k(D,`navigation-menu-viewport-positioner`):null,ye=D?k(D,`navigation-menu-positioner`):null,H=ve??ye,be=H?k(H,`navigation-menu-portal`):null,U=D?i({content:D,root:p,enabled:!0,wrapperSlot:H?void 0:`navigation-menu-viewport-positioner`,container:H??void 0,mountTarget:H?be??H:void 0}):null,xe=()=>{let e=U?.container;e instanceof HTMLElement&&(e.style.position=``,e.style.top=``,e.style.left=``,e.style.width=``,e.style.height=``,e.style.margin=``,e.style.willChange=``,e.style.pointerEvents=``,e.style.transform=``,e.style.removeProperty(`--transform-origin`),e.removeAttribute(`data-instant`))},Se=()=>{D?.removeAttribute(`data-instant`);let e=U?.container;e instanceof HTMLElement&&e.removeAttribute(`data-instant`)},Ce=D?a({element:D,onExitComplete:()=>{me||(Se(),xe(),B=0,he=0,U?.restore(),D.hidden=!0,D.style.pointerEvents=`none`)}}):null,we=e=>{if(!D)return;let t=_e.get(e)??{originalParent:null,originalNextSibling:null,mountedInViewport:!1};t.mountedInViewport||(t.originalParent=e.parentNode,t.originalNextSibling=e.nextSibling,t.mountedInViewport=!0,_e.set(e,t)),e.parentNode!==D&&D.appendChild(e)},Te=e=>{let t=_e.get(e);if(!t||!t.mountedInViewport)return;let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.mountedInViewport=!1,t.originalParent=null,t.originalNextSibling=null},Ee=()=>{if(!D||!U)return;let e=U.container,t=p.ownerDocument.defaultView??window,n=p.getBoundingClientRect(),r=n.top+t.scrollY+he,i=n.left+t.scrollX+B;e.style.position=`absolute`,e.style.top=`${r}px`,e.style.left=`${i}px`,e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.margin=`0`,e.style.willChange=`top,left`,e.style.pointerEvents=`none`},De=null,Oe=e=>{De?.disconnect(),De=null,!(!D||!e)&&(De=new ResizeObserver(()=>{let t=ke(e.item,e.content);mt(e.content,e.trigger,t)}),De.observe(e.content))};V.push(()=>De?.disconnect()),V.push(()=>{Se(),ge.forEach(e=>e.cleanup()),ge.clear(),_e.forEach((e,t)=>{Te(t),t.hidden=!0,t.style.pointerEvents=`none`}),_e.clear(),xe(),B=0,he=0,Ce?.cleanup(),U?.cleanup()});let W=new Map,ke=(e,t)=>({side:m.side??l(t,`side`,ne)??l(e,`side`,ne)??ae,align:m.align??l(t,`align`,_)??l(e,`align`,_)??oe,sideOffset:m.sideOffset??u(t,`sideOffset`)??u(e,`sideOffset`)??se,alignOffset:m.alignOffset??u(t,`alignOffset`)??u(e,`alignOffset`)??ce}),Ae=0;E.forEach(e=>{let t=e.dataset.value;if(!t)return;let n=d(e,`navigation-menu-trigger`),r=d(e,`navigation-menu-content`);if(n&&r){W.set(t,{value:t,item:e,trigger:n,content:r,index:Ae++}),ge.set(r,a({element:r,onExitComplete:()=>{me||(Te(r),r.hidden=!0,r.style.pointerEvents=`none`)}}));let i=de(t),o=s(n,`nav-menu-trigger-${i}`),c=s(r,`nav-menu-content-${i}`);n.setAttribute(`aria-haspopup`,`true`),n.setAttribute(`aria-controls`,c),r.setAttribute(`aria-labelledby`,o)}}),Array.from(W.values()).map(e=>e.trigger);let je=`a[href], button:not([disabled]), [role="link"], [role="button"], [tabindex]:not([tabindex="-1"])`,Me=e=>{let t=e?.closest(`[data-slot="navigation-menu-item"]`);if(!t)return null;let n=t.dataset.value;if(!n)return null;let r=W.get(n);return!r||r.item!==t?null:r},Ne=e=>{if(e.matches(je))return e;let t=e.querySelectorAll(je);for(let n of t)if(e.contains(n)&&!n.closest(`[data-slot="navigation-menu-content"]`)&&!(n.hidden||n.closest(`[hidden]`)))return n;return null},G=[],Pe=new Map;E.forEach(e=>{let t=Me(e);if(t){let e={kind:`submenu`,element:t.trigger,value:t.value,trigger:t.trigger};G.push(e),Pe.set(e.element,e);return}let n=Ne(e);if(!n)return;let r={kind:`plain`,element:n};G.push(r),Pe.set(r.element,r)});let Fe=e=>{let t=e instanceof HTMLElement?e:null;if(!t)return null;let n=t;for(;n&&n!==T;){let e=Pe.get(n);if(e)return e;n=n.parentElement}return null},Ie=e=>{let t=Fe(e);return t?.kind===`plain`?t:null},Le=(e,t={})=>{let n=p.ownerDocument,r=t.preserveOpenOnPlain??!1;return e.kind===`submenu`?(e.trigger.focus(),n.activeElement===e.trigger?(Z(e.trigger),!0):!1):(A!==null&&!r&&$(),e.element.focus(),n.activeElement===e.element?(A!==null&&r?Z():X(e.element),!0):!1)},Re=(e,t,n={})=>{for(let r=e+t;r>=0&&r<G.length;r+=t){let e=G[r];if(e&&Le(e,n))return!0}return!1},ze=(e,t,n={})=>{let r=G.indexOf(e);return r===-1?!1:Re(r,t,n)},Be=(e,t,n={})=>{let r=G.findIndex(t=>t.kind===`submenu`&&t.trigger===e);return r===-1?!1:Re(r,t,n)},Ve=e=>{if(!(e instanceof Node)||!T.contains(e))return!1;let t=e instanceof HTMLElement?e:e.parentElement;return!t||t.closest(`[data-slot="navigation-menu-indicator"]`)||Me(t)?!1:t.closest(`[data-slot="navigation-menu-item"]`)?!0:!!t.closest(`a[href], button, [role='link'], [role='button']`)},He=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,Ue=e=>Array.from(e.querySelectorAll(He)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),We=e=>!e.isConnected||e.hidden||e.closest(`[hidden]`)||`disabled`in e&&e.disabled||e.getAttribute(`aria-hidden`)===`true`||e.getAttribute(`tabindex`)===`-1`?!1:e.matches(He)?!0:e.tabIndex>=0,Ge=e=>{if(p.contains(e)||D?.contains(e))return!0;let t=U?.container;if(t instanceof HTMLElement&&t.contains(e))return!0;for(let{content:t}of W.values())if(t.contains(e))return!0;return!1},Ke=()=>{let e=p.ownerDocument,t=Array.from(e.querySelectorAll(`*`));for(let n of t)if(We(n)&&!Ge(n)&&(p.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0&&(n.focus(),e.activeElement===n))return!0;return!1},qe=e=>{requestAnimationFrame(()=>{if(A!==e)return;let t=W.get(e);if(!t)return;let n=Ue(t.content)[0];n?n.focus():t.content.focus()})},K=()=>{N&&=(clearTimeout(N),null),fe&&=(clearTimeout(fe),null)},q=()=>{K(),j=null},Je=()=>{I=null,L=null},Ye=()=>{z!==null&&(cancelAnimationFrame(z),z=null)},J=null,Xe=()=>{if(!D)return null;let e=U?.container;return e instanceof HTMLElement?e:D.parentElement instanceof HTMLElement?D.parentElement:D},Ze=()=>{let e=Xe();return J||(J=document.createElement(`div`),J.setAttribute(`data-slot`,`navigation-menu-bridge`),J.style.cssText=`position: absolute; pointer-events: auto; z-index: 0; display: none;`,V.push(h(J,`pointerenter`,()=>{K()}),h(J,`pointerleave`,e=>{if(F||A===null)return;let t=e.relatedTarget;pt(t)||t&&n(p,t)||(Q(null),X(null))}))),e&&J.parentElement!==e&&e.insertBefore(J,e.firstChild),J},Qe=()=>{J&&(J.style.height=`0`,J.style.width=`0`,J.style.top=`0px`,J.style.left=`0px`,J.style.right=`0px`,J.style.bottom=`auto`,J.style.transform=`none`,J.style.clipPath=`none`,J.style.display=`none`)},$e=()=>{if(!S)return null;let e=p.ownerDocument.body;return e?(R||(R=p.ownerDocument.createElement(`div`),R.setAttribute(`data-slot`,`navigation-menu-safe-triangle`),R.style.cssText=[`position: fixed`,`pointer-events: none`,`display: none`,`z-index: 2147483647`,`background: rgba(255, 0, 0, 0.18)`,`border: 1px solid rgba(255, 0, 0, 0.45)`].join(`; `)),R.parentElement!==e&&e.appendChild(R),R):null},et=()=>{R&&(R.style.width=`0`,R.style.height=`0`,R.style.clipPath=`none`,R.style.display=`none`)},Y=()=>{S||et()},tt=e=>{let t=$e();if(!t)return;let n=e.apex.x,r=e.apex.y,i=e.edgeA.x,a=e.edgeA.y,o=e.edgeB.x,s=e.edgeB.y,c=Math.min(n,i,o),l=Math.min(r,a,s),u=Math.max(n,i,o),d=Math.max(r,a,s),f=Math.max(1,u-c),p=Math.max(1,d-l),m=(e,t)=>`${(e-c)/f*100}% ${(t-l)/p*100}%`;t.style.display=`block`,t.style.left=`${c}px`,t.style.top=`${l}px`,t.style.width=`${f}px`,t.style.height=`${p}px`,t.style.clipPath=`polygon(${m(n,r)}, ${m(i,a)}, ${m(o,s)})`},nt=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),rt=(e,t,n,r)=>{let i=nt(e,t,n),a=nt(e,n,r),o=nt(e,r,t);return!((i<0||a<0||o<0)&&(i>0||a>0||o>0))},it=(e,t,n)=>{let r=.5;if(n.top>=t.bottom-r)return[{x:n.left,y:n.top},{x:n.right,y:n.top}];if(n.bottom<=t.top+r)return[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}];if(n.left>=t.right-r)return[{x:n.left,y:n.top},{x:n.left,y:n.bottom}];if(n.right<=t.left+r)return[{x:n.right,y:n.top},{x:n.right,y:n.bottom}];let i=[[{x:n.left,y:n.top},{x:n.right,y:n.top}],[{x:n.right,y:n.top},{x:n.right,y:n.bottom}],[{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}],[{x:n.left,y:n.top},{x:n.left,y:n.bottom}]],a=([t,n])=>t.y===n.y?Math.abs(e.y-t.y):Math.abs(e.x-t.x),o=i[0],s=a(o);for(let e=1;e<i.length;e++){let t=i[e],n=a(t);n<s&&(o=t,s=n)}return o},at=()=>A?W.get(A)??null:null,ot=(e,t,n)=>{if(n.width<=0||n.height<=0)return null;let r={x:e.left+e.width/2,y:e.top+e.height*.62},[i,a]=it(r,t,n);if(i.x===a.x){let e=Math.min(i.y,a.y),t=Math.max(i.y,a.y),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:i.x,y:e+r},a={x:a.x,y:t-r}}else{let e=Math.min(i.x,a.x),t=Math.max(i.x,a.x),n=t-e,r=n<=28?0:Math.min(10,(n-28)/2);i={x:e+r,y:i.y},a={x:t-r,y:a.y}}return{apex:r,edgeA:i,edgeB:a}},st=()=>{if(!ue||!D||A===null)return null;let e=at();if(!e)return null;let t=p.getBoundingClientRect(),n=e.trigger.getBoundingClientRect(),r=D.getBoundingClientRect(),i=e.content.getBoundingClientRect();return ot(n,t,r.width>0&&r.height>0?r:i)},ct=e=>{let t=st();return t?rt({x:e.clientX,y:e.clientY},t.apex,t.edgeA,t.edgeB):!1},lt=(e,t)=>({x:e.x-t.left,y:e.y-t.top}),ut=e=>{if(e.length<=1)return e.slice();let t=e=>`${e.x.toFixed(3)}:${e.y.toFixed(3)}`,n=new Map;for(let r of e)n.set(t(r),r);let r=Array.from(n.values()).sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x);if(r.length<=2)return r;let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=[];for(let e of r){for(;a.length>=2&&i(a[a.length-2],a[a.length-1],e)<=0;)a.pop();a.push(e)}let o=[];for(let e=r.length-1;e>=0;e--){let t=r[e];for(;o.length>=2&&i(o[o.length-2],o[o.length-1],t)<=0;)o.pop();o.push(t)}return a.pop(),o.pop(),a.concat(o)},dt=e=>{if(e.length<3){Qe();return}let t=Ze(),n=t.parentElement,r=ut(n&&n===U?.container?e.map(e=>({x:e.x-B,y:e.y-he})):e);if(r.length<3){Qe();return}let i=Math.min(...r.map(e=>e.x)),a=Math.min(...r.map(e=>e.y)),o=Math.max(...r.map(e=>e.x)),s=Math.max(...r.map(e=>e.y)),c=Math.max(1,o-i),l=Math.max(1,s-a),u=e=>`${(e.x-i)/c*100}% ${(e.y-a)/l*100}%`;t.style.display=`block`,t.style.transform=`none`,t.style.bottom=`auto`,t.style.right=`auto`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.width=`${c}px`,t.style.height=`${l}px`,t.style.clipPath=`polygon(${r.map(u).join(`, `)})`},ft=()=>{if(!S)return;let e=st();if(!e){et();return}tt(e)},pt=e=>{if(!e)return!1;if(at()?.content.contains(e)||D?.contains(e)||J?.contains(e))return!0;let t=U?.container;return!!(t instanceof HTMLElement&&t.contains(e))};V.push(Y),V.push(Ye),V.push(Qe),V.push(()=>{et(),R?.parentElement&&R.parentElement.removeChild(R),R=null});let mt=(e,n,r)=>{D&&requestAnimationFrame(()=>{let i=e.firstElementChild,a=e.lastElementChild,o=i?getComputedStyle(i):null,s=a?getComputedStyle(a):null,c=o&&parseFloat(o.marginTop)||0,l=s&&parseFloat(s.marginBottom)||0,u=(...e)=>{let t=0;for(let n of e)Number.isFinite(n)&&(t=Math.max(t,n));return t},d=e.getBoundingClientRect(),f=u(d.width,e.scrollWidth,e.offsetWidth,e.clientWidth),m=u(d.height,e.scrollHeight,e.offsetHeight,e.clientHeight)+c+l,h={top:d.top,left:d.left,width:f,height:m,right:d.left+f,bottom:d.top+m},ee=getComputedStyle(D),te=parseFloat(ee.marginTop)||0;D.style.setProperty(`--viewport-width`,`${f}px`),D.style.setProperty(`--viewport-height`,`${m}px`);let g=p.getBoundingClientRect(),_=n.getBoundingClientRect(),v=t({anchorRect:_,contentRect:h,side:r.side,align:r.align,sideOffset:r.sideOffset,alignOffset:r.alignOffset,avoidCollisions:!1,collisionPadding:0,allowedSides:ne}),y=v.x-g.left,b=v.y-g.top;B=y,he=b;let x=re(v.side,v.align,_),ie=x.x-(g.left+y),ae=x.y-(g.top+b),oe=x.x-g.left,se=x.y-g.top,ce=`${ie}px ${ae}px`,le=`${oe}px ${se}px`;D.style.top=`0px`,D.style.left=`0px`,D.style.willChange=`transform,width,height`,D.style.setProperty(`--transform-origin`,ce),e.style.top=`0px`,e.style.left=`0px`,e.style.setProperty(`--transform-origin`,ce),D.setAttribute(`data-side`,v.side),D.setAttribute(`data-align`,v.align),e.setAttribute(`data-side`,v.side),e.setAttribute(`data-align`,v.align);let S=U?.container;S&&S!==D&&(S.setAttribute(`data-side`,v.side),S.setAttribute(`data-align`,v.align),S.style.setProperty(`--transform-origin`,le)),Ee();let C=D.getBoundingClientRect(),de=[],w=Math.max(0,C.top-g.bottom),T=Math.max(0,g.top-C.bottom),E=Math.max(0,C.left-g.right),O=Math.max(0,g.left-C.right),k=Math.max(0,c+te),A=Math.max(w,T,k),j=Math.max(E,O),M=ue?ot(_,g,C):null,N=(e,t,n,r)=>{n<=0||r<=0||de.push({x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r})};if(A>=j&&A>0){let e=Math.max(w,T,k),t=y,n=T>w&&T>=k?b+m:b-e,r=f;if(M){let e=Math.min(M.edgeA.x,M.edgeB.x)-g.left,n=Math.max(M.edgeA.x,M.edgeB.x)-g.left;t=e-8,r=n-e+16}N(t,n,r,e)}else if(j>0){let e=Math.max(E,O),t=b,n=O>E?y+f:y-e,r=m;if(M){let e=Math.min(M.edgeA.y,M.edgeB.y)-g.top,n=Math.max(M.edgeA.y,M.edgeB.y)-g.top;t=e-8,r=n-e+16}N(n,t,e,r)}if(M){let e=lt(M.apex,g),t=lt(M.edgeA,g),n=lt(M.edgeB,g);de.push(e,t,n)}dt(de),ft()})},ht=e=>M===-1||e>M?`right`:`left`,X=e=>{if(!O)return;if(P=e,!e){Ye(),O.removeAttribute(`data-instant`),O.setAttribute(`data-state`,`hidden`);return}O.getAttribute(`data-state`)!==`visible`&&(Ye(),O.setAttribute(`data-instant`,``),z=requestAnimationFrame(()=>{z=requestAnimationFrame(()=>{O.removeAttribute(`data-instant`),z=null})}));let t=T.getBoundingClientRect(),n=e.getBoundingClientRect();O.style.setProperty(`--indicator-left`,`${n.left-t.left}px`),O.style.setProperty(`--indicator-width`,`${n.width}px`),O.style.setProperty(`--indicator-top`,`${n.top-t.top}px`);let r=(D&&parseFloat(getComputedStyle(D).marginTop)||0)<1?1:0;O.style.setProperty(`--indicator-height`,`${n.height-r}px`),O.setAttribute(`data-state`,`visible`)},gt=()=>A?W.get(A)?.trigger??null:null,Z=(e=null)=>{let t=gt();if(t){X(t);return}X(e)},Q=(e,t=!1)=>{if(Y(),e===A){e===null?q():K();return}if(!t&&e!==null&&e===j)return;K(),j=e===null?null:e;let r=()=>{let t=A,r=e?W.get(e):null,i=t!==null&&e!==null&&t!==e,a=i&&r?ht(r.index):null,s=document.activeElement;if(e===null&&s&&t){let e=W.get(t);e&&n(e.content,s)&&e.trigger.focus()}if(W.forEach(({trigger:n,content:r,item:i},o)=>{let s=o===e,c=o===t;if(te(n,`expanded`,s),n.setAttribute(`data-state`,s?`open`:`closed`),i.setAttribute(`data-state`,s?`open`:`closed`),!s){let e=ge.get(r);if(r.setAttribute(`data-state`,`inactive`),r.setAttribute(`aria-hidden`,`true`),w(r,!0),r.style.pointerEvents=`none`,c&&a){let e=a===`right`?`to-left`:`to-right`;r.setAttribute(`data-motion`,e)}else c&&r.removeAttribute(`data-motion`);c?e?.exit():e?.isExiting||(r.removeAttribute(`data-motion`),Te(r),r.hidden=!0)}}),r){if(U?.mount(),D&&(D.hidden=!1),t===null&&Ce?.enter(),we(r.content),ge.get(r.content)?.enter(),a){let e=a===`right`?`from-right`:`from-left`;r.content.setAttribute(`data-motion`,e)}else r.content.removeAttribute(`data-motion`);r.content.setAttribute(`data-state`,`active`),r.content.removeAttribute(`aria-hidden`),w(r.content,!1),r.content.hidden=!1,r.content.style.pointerEvents=`auto`,M=r.index;let e=ke(r.item,r.content);mt(r.content,r.trigger,e),Oe(r),X(r.trigger)}else Qe(),Y(),Ce?.exit(),Oe(null);let c=e!==null;if(p.setAttribute(`data-state`,c?`open`:`closed`),a?p.setAttribute(`data-motion`,a===`right`?`from-right`:`from-left`):p.removeAttribute(`data-motion`),D){D.setAttribute(`data-state`,c?`open`:`closed`),D.style.pointerEvents=c?`auto`:`none`;let e=U?.container;c&&!i?(D.setAttribute(`data-instant`,``),e?.setAttribute(`data-instant`,``)):i?Se():c||Se(),a&&D.style.setProperty(`--motion-direction`,a===`right`?`1`:`-1`)}A=e,j=null,e===null&&X(null),ft(),o(p,`navigation-menu:change`,{value:e}),C?.(e)};t?r():e!==null&&A===null?N=setTimeout(r,b):e!==null&&A!==null?r():fe=setTimeout(r,x)};p.setAttribute(`data-state`,`closed`),D&&(D.setAttribute(`data-state`,`closed`),D.hidden=!0,D.style.pointerEvents=`none`),O&&O.setAttribute(`data-state`,`hidden`),W.forEach(({trigger:e,content:t,item:n})=>{e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&(e.type=`button`),te(e,`expanded`,!1),e.setAttribute(`data-state`,`closed`),e.tabIndex=0,n.setAttribute(`data-state`,`closed`),t.setAttribute(`data-state`,`inactive`),t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,w(t,!0),t.hidden=!0,t.style.pointerEvents=`none`}),W.forEach(({item:e,trigger:t},r)=>{V.push(h(t,`pointerenter`,e=>{if(!F){if(A!==r&&ct(e))return;X(t)}})),V.push(h(e,`pointerenter`,e=>{if(!F){if(A!==r&&ct(e))return;Q(r)}})),V.push(h(e,`pointerleave`,e=>{if(j===r&&A===null&&q(),A===r&&!F){let t=e.relatedTarget;if(pt(t))return;(!t||!n(p,t))&&(Q(null),X(null))}})),V.push(h(t,`focus`,()=>{if(I===t){I=null;return}ie&&Q(r,!0),Z(t)})),V.push(h(t,`pointerdown`,()=>{I=t,L=t}),h(t,`keydown`,()=>{L=null})),V.push(h(t,`click`,()=>{let e=L===t;L=null,I=null,q(),A===r&&F?(F=!1,Q(null,!0),X(null)):A===r&&!F?(F=!0,X(t),e||qe(r)):(F=!0,Q(r,!0),X(t),e||qe(r))}))}),V.push(h(T,`pointerover`,e=>{let t=e;if(t.pointerType===`touch`)return;let n=Ie(t.target);if(n){if(A!==null){if(F)return;$()}X(n.element);return}A!==null&&(F||Ve(t.target)&&$())}),h(T,`click`,e=>{A!==null&&Ve(e.target)&&$()})),V.push(h(T,`focusin`,e=>{let t=Ie(e.target);if(t){if(A!==null){Z();return}X(t.element)}}),h(p,`pointerenter`,()=>{pe=!0}),h(p,`pointerleave`,e=>{let t=e.relatedTarget;if(!pt(t)&&(pe=!1,!F)){if(ct(e)){K();return}Q(null),X(null)}}),h(p,`pointerdown`,()=>{Y(),q()})),D&&V.push(h(D,`pointerenter`,()=>{Y(),K()}),h(D,`transitionend`,e=>{if(e.target!==D)return;let t=A?W.get(A):null;if(t){let e=ke(t.item,t.content);mt(t.content,t.trigger,e)}})),W.forEach(({content:e})=>{V.push(h(e,`pointerenter`,()=>{Y(),K()}),h(e,`pointerleave`,e=>{if(F)return;let t=e.relatedTarget;pt(t)||n(p,t)||(Q(null),X(null))}))}),V.push(h(T,`keydown`,e=>{let t=Fe(e.target);if(!t)return;let n=G.indexOf(t);if(n===-1)return;let r=n;switch(e.key){case`Tab`:if(e.shiftKey||A===null)return;(ze(t,1,{preserveOpenOnPlain:!0})||Ke())&&e.preventDefault();return;case`ArrowLeft`:r=n-1,r<0&&(r=G.length-1);break;case`ArrowRight`:r=n+1,r>=G.length&&(r=0);break;case`ArrowDown`:if(t.kind===`submenu`){e.preventDefault();let n=t.value;F=!0,Q(n,!0),qe(n)}return;case`Home`:r=0;break;case`End`:r=G.length-1;break;case`Escape`:F=!1,Q(null,!0),X(null);return;default:return}e.preventDefault();let i=G[r];i&&Le(i,{preserveOpenOnPlain:!0})})),W.forEach(({content:e,trigger:t})=>{V.push(h(e,`keydown`,n=>{let r=n.target,i=Ue(e),a=i.indexOf(r);if(a!==-1)switch(n.key){case`Tab`:if(!n.shiftKey&&a===i.length-1){(Be(t,1,{preserveOpenOnPlain:!0})||Ke())&&n.preventDefault();return}if(n.shiftKey&&a===0){n.preventDefault(),t.focus();return}return;case`ArrowDown`:case`ArrowRight`:{n.preventDefault();let e=a+1;e<i.length&&i[e]?.focus();break}case`ArrowUp`:case`ArrowLeft`:n.preventDefault(),a===0?t.focus():i[a-1]?.focus();break;case`Escape`:n.preventDefault(),F=!1,Q(null,!0),X(null),t.focus();break}}))});let _t=()=>n(p,document.activeElement)||pe||F,$=()=>{Y(),q(),Je(),F=!1,Q(null,!0),X(null),ft()};V.push(h(document,`focusin`,e=>{let t=e.target;if(!n(p,t)){if(A!==null){$();return}X(null)}})),V.push(r({root:p,isOpen:()=>A!==null&&_t(),onDismiss:$,closeOnClickOutside:!0,closeOnEscape:!0,preventEscapeDefault:!1,isInside:e=>!!e&&n(p,e)})),V.push(h(window,`resize`,()=>{A&&requestAnimationFrame(()=>Ee()),(A||P)&&requestAnimationFrame(()=>Z(P))}),h(T,`scroll`,()=>{(A||P)&&requestAnimationFrame(()=>Z(P))})),V.push(h(p,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)$();else if(W.has(t.value)){F=!0,Q(t.value,!0);let e=W.get(t.value);e&&X(e.trigger)}}}));let vt={get value(){return A},open:e=>Q(e,!0),close:()=>$(),destroy:()=>{me=!0,q(),Je(),V.forEach(e=>e()),V.length=0,e(p,y,vt)}};return g(p,y,vt),vt}function x(e=document){let t=[];for(let n of p(e,`navigation-menu`))m(n,y)||t.push(b(n));return t}export{x as create,b as createNavigationMenu};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-slot/navigation-menu",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.134",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
],
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@data-slot/core": "0.2.
|
|
38
|
+
"@data-slot/core": "0.2.134"
|
|
39
39
|
}
|
|
40
40
|
}
|