@data-slot/navigation-menu 0.2.30 → 0.2.31

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 CHANGED
@@ -1 +1 @@
1
- const e=(e,t)=>e.querySelector(`[data-slot="${t}"]`),t=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],n=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],r=new WeakMap;function i(e,t,n){if(typeof process<`u`&&process.env?.NODE_ENV===`production`)return;let i=r.get(e);i||(i=new Set,r.set(e,i)),!i.has(t)&&(i.add(t),console.warn(`[@data-slot] ${n}`))}function a(e){let t=`data-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`,n=`data-${e}`;return t===n?[t]:[t,n]}function o(e,t){for(let n of a(t))if(e.hasAttribute(n))return e.getAttribute(n);return null}function s(e,t){return a(t).some(t=>e.hasAttribute(t))}const c=new Set([``,`true`,`1`,`yes`]),l=new Set([`false`,`0`,`no`]);function u(e,t){if(!s(e,t))return;let n=o(e,t);if(n===null)return;let r=n.toLowerCase();if(c.has(r))return!0;if(l.has(r))return!1;i(e,t,`Invalid boolean value "${n}" for data-${t}. Expected: true/false/1/0/yes/no or empty.`)}function d(e,t){let n=o(e,t);if(n===null||n===``)return;let r=Number(n);if(Number.isNaN(r)||!Number.isFinite(r)){i(e,t,`Invalid number value "${n}" for data-${t}.`);return}return r}function f(e,t,n){let r=o(e,t);if(r!==null){if(n.includes(r))return r;i(e,t,`Invalid value "${r}" for data-${t}. Expected one of: ${n.join(`, `)}.`)}}const p=Symbol.for(`data-slot.portal-owner`);let m=0;const h=(e,t)=>e.id||=`${t}-${++m}`,g=(e,t,n)=>{n===null?e.removeAttribute(`aria-${t}`):e.setAttribute(`aria-${t}`,String(n))};function _(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const v=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n})),y=[`start`,`center`,`end`];function b(n,r={}){let i=r.delayOpen??d(n,`delayOpen`)??200,a=r.delayClose??d(n,`delayClose`)??150,o=r.openOnFocus??u(n,`openOnFocus`)??!0,s=r.onValueChange,c=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),l=(e,t)=>{`inert`in e&&(e.inert=t)},p=e(n,`navigation-menu-list`),m=t(n,`navigation-menu-item`),b=e(n,`navigation-menu-viewport`),x=e(n,`navigation-menu-indicator`);if(!p||m.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let S=null,C=null,w=-1,T=null,E=null,D=null,O=!1,k=!1,A=!1,j=[],M=null,N=e=>{M?.disconnect(),M=null,!(!b||!e)&&(M=new ResizeObserver(()=>U(e.content,e.trigger,e.align)),M.observe(e.content))};j.push(()=>M?.disconnect());let P=new Map,F=0;m.forEach(t=>{let r=t.dataset.value;if(!r)return;let i=e(t,`navigation-menu-trigger`),a=e(t,`navigation-menu-content`);if(i&&a){let e=f(a,`align`,y)??f(t,`align`,y)??f(n,`align`,y)??`start`;P.set(r,{item:t,trigger:i,content:a,index:F++,align:e});let o=c(r),s=h(i,`nav-menu-trigger-${o}`),l=h(a,`nav-menu-content-${o}`);i.setAttribute(`aria-haspopup`,`true`),i.setAttribute(`aria-controls`,l),a.setAttribute(`aria-labelledby`,s)}});let I=Array.from(P.values()).map(e=>e.trigger),L=new Map;for(let[e,t]of P)L.set(t.trigger,e);let R=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,z=e=>Array.from(e.querySelectorAll(R)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),B=()=>{T&&(clearTimeout(T),T=null),E&&(clearTimeout(E),E=null)},V=null,H=()=>(V||(V=document.createElement(`div`),V.setAttribute(`data-slot`,`navigation-menu-bridge`),V.style.cssText=`position: absolute; left: 0; right: 0; top: 0; pointer-events: auto; z-index: -1;`,b&&b.insertBefore(V,b.firstChild),j.push(_(V,`pointerenter`,()=>{B()}))),V),U=(e,t,r)=>{b&&requestAnimationFrame(()=>{let i=e.firstElementChild,a=i?.getBoundingClientRect(),o=i?getComputedStyle(i):null,s=o&&parseFloat(o.marginTop)||0,c=o&&parseFloat(o.marginBottom)||0,l=a??e.getBoundingClientRect(),u=l.height+s+c,d=getComputedStyle(b),f=parseFloat(d.marginTop)||0,p=e.getBoundingClientRect();b.style.setProperty(`--viewport-width`,`${p.width}px`),b.style.setProperty(`--viewport-height`,`${u}px`);let m=n.getBoundingClientRect(),h=t.getBoundingClientRect(),g;g=r===`center`?h.left-m.left+h.width/2-l.width/2:r===`end`?h.right-m.left-l.width:h.left-m.left,b.style.setProperty(`--viewport-left`,`${g}px`),b.style.left=`${g}px`,e.style.left=`${g}px`;let _=s+f;if(_>0){let e=H();e.style.height=`${_}px`,e.style.transform=`translateY(-${_}px)`}else V&&(V.style.height=`0`)})},W=e=>w===-1||e>w?`right`:`left`,G=e=>{if(!x)return;if(D=e,!e){x.setAttribute(`data-state`,`hidden`);return}let t=p.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,i=r<1?1:0;x.style.setProperty(`--indicator-height`,`${n.height-i}px`),x.setAttribute(`data-state`,`visible`)},K=(e,t=!1)=>{if(e===S){B();return}if(e!==null&&e===C){B();return}B(),C=e===null?null:e;let r=()=>{let t=S,r=e?P.get(e):null,i=t!==null&&e!==null&&t!==e,a=i&&r?W(r.index):null,o=document.activeElement;if(e===null&&o&&n.contains(o)){let e=t?P.get(t)?.trigger:null;e&&e.focus()}if(P.forEach(({trigger:n,content:r,item:i},o)=>{let s=o===e,c=o===t;if(g(n,`expanded`,s),n.setAttribute(`data-state`,s?`open`:`closed`),s||c&&e===null?n.tabIndex=0:n.tabIndex=-1,i.setAttribute(`data-state`,s?`open`:`closed`),!s)if(r.setAttribute(`data-state`,`inactive`),r.setAttribute(`aria-hidden`,`true`),l(r,!0),r.hidden=!0,c&&a){let e=a===`right`?`to-left`:`to-right`;r.setAttribute(`data-motion`,e)}else r.removeAttribute(`data-motion`)}),r){if(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`),l(r.content,!1),r.content.hidden=!1,w=r.index,U(r.content,r.trigger,r.align),N(r),G(r.trigger)}else N(null);let c=e!==null;n.setAttribute(`data-state`,c?`open`:`closed`),a?n.setAttribute(`data-motion`,a===`right`?`from-right`:`from-left`):n.removeAttribute(`data-motion`),b&&(b.setAttribute(`data-state`,c?`open`:`closed`),c&&!i?b.setAttribute(`data-instant`,``):i&&b.removeAttribute(`data-instant`),a&&b.style.setProperty(`--motion-direction`,a===`right`?`1`:`-1`)),S=e,C=null,e===null&&G(null),v(n,`navigation-menu:change`,{value:e}),s?.(e)};t?r():e!==null&&S===null?T=setTimeout(r,i):e!==null&&S!==null?r():E=setTimeout(r,a)};n.setAttribute(`data-state`,`closed`),b&&b.setAttribute(`data-state`,`closed`),x&&x.setAttribute(`data-state`,`hidden`),P.forEach(({trigger:e,content:t,item:n})=>{e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&(e.type=`button`),g(e,`expanded`,!1),e.setAttribute(`data-state`,`closed`),e.tabIndex=e===I[0]?0:-1,n.setAttribute(`data-state`,`closed`),t.setAttribute(`data-state`,`inactive`),t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,l(t,!0),t.hidden=!0}),P.forEach(({item:e,trigger:t},n)=>{j.push(_(t,`pointerenter`,()=>{O||G(t)})),j.push(_(e,`pointerenter`,()=>{O||K(n)})),j.push(_(e,`pointerleave`,()=>{C===n&&S===null&&(B(),C=null)})),j.push(_(t,`focus`,()=>{k||(o&&K(n,!0),G(t))})),j.push(_(t,`pointerdown`,()=>{k=!0})),j.push(_(t,`click`,()=>{B(),S===n&&O?(O=!1,K(null,!0),G(null)):S===n&&!O?(O=!0,G(t)):(O=!0,K(n,!0),G(t)),k=!1}))}),j.push(_(n,`pointerenter`,()=>{A=!0}),_(n,`pointerleave`,()=>{A=!1,O||(K(null),G(null))}),_(n,`pointerdown`,B)),b&&j.push(_(b,`pointerenter`,()=>{B()}),_(b,`transitionend`,e=>{if(e.target!==b)return;let t=S?P.get(S):null;t&&U(t.content,t.trigger,t.align)})),P.forEach(({content:e})=>{j.push(_(e,`pointerenter`,()=>{B()}))}),j.push(_(p,`keydown`,e=>{let t=e.target,n=I.indexOf(t);if(n===-1)return;let r=L.get(t)??null,i=n;switch(e.key){case`ArrowLeft`:i=n-1,i<0&&(i=I.length-1);break;case`ArrowRight`:i=n+1,i>=I.length&&(i=0);break;case`ArrowDown`:e.preventDefault(),r&&(O=!0,K(r,!0),requestAnimationFrame(()=>{let e=P.get(r);if(!e)return;let t=z(e.content),n=t[0];n?n.focus():e.content.focus()}));return;case`Home`:i=0;break;case`End`:i=I.length-1;break;case`Escape`:O=!1,K(null,!0),G(null);return;default:return}e.preventDefault();let a=I[i];a&&(I.forEach(e=>e.tabIndex=e===a?0:-1),a.focus(),G(a))})),P.forEach(({content:e,trigger:t})=>{j.push(_(e,`keydown`,n=>{let r=n.target,i=z(e),a=i.indexOf(r);if(a!==-1)switch(n.key){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(),O=!1,K(null,!0),G(null),t.focus();break}}))});let q=()=>n.contains(document.activeElement)||A||O;j.push(_(document,`pointerup`,()=>{k=!1},{capture:!0}),_(document,`pointercancel`,()=>{k=!1},{capture:!0})),j.push(_(document,`focusin`,e=>{S!==null&&(n.contains(e.target)||(O=!1,K(null,!0),G(null)))})),j.push(_(document,`pointerdown`,e=>{S!==null&&q()&&(n.contains(e.target)||(O=!1,K(null,!0),G(null)))})),j.push(_(document,`keydown`,e=>{e.key!==`Escape`||S===null||q()&&(O=!1,K(null,!0),G(null))})),j.push(_(window,`resize`,()=>{D&&requestAnimationFrame(()=>G(D))}),_(p,`scroll`,()=>{D&&requestAnimationFrame(()=>G(D))})),j.push(_(n,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)O=!1,K(null,!0),G(null);else if(P.has(t.value)){O=!0,K(t.value,!0);let e=P.get(t.value);e&&G(e.trigger)}}}));let J={get value(){return S},open:e=>K(e,!0),close:()=>K(null,!0),destroy:()=>{B(),j.forEach(e=>e()),j.length=0}};return J}const x=new WeakSet;function S(e=document){let t=[];for(let r of n(e,`navigation-menu`)){if(x.has(r))continue;x.add(r),t.push(b(r))}return t}exports.create=S,exports.createNavigationMenu=b;
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`@data-slot/core`)),l=[`start`,`center`,`end`];function u(e,t={}){let n=t.delayOpen??(0,c.getDataNumber)(e,`delayOpen`)??200,r=t.delayClose??(0,c.getDataNumber)(e,`delayClose`)??150,i=t.openOnFocus??(0,c.getDataBool)(e,`openOnFocus`)??!0,a=t.onValueChange,o=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),s=(e,t)=>{`inert`in e&&(e.inert=t)},u=(0,c.getPart)(e,`navigation-menu-list`),d=(0,c.getParts)(e,`navigation-menu-item`),f=(0,c.getPart)(e,`navigation-menu-viewport`),p=(0,c.getPart)(e,`navigation-menu-indicator`);if(!u||d.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let m=null,h=null,g=-1,_=null,v=null,y=null,b=!1,x=!1,S=!1,C=[],w=null,T=e=>{w?.disconnect(),w=null,!(!f||!e)&&(w=new ResizeObserver(()=>F(e.content,e.trigger,e.align)),w.observe(e.content))};C.push(()=>w?.disconnect());let E=new Map,D=0;d.forEach(t=>{let n=t.dataset.value;if(!n)return;let r=(0,c.getPart)(t,`navigation-menu-trigger`),i=(0,c.getPart)(t,`navigation-menu-content`);if(r&&i){let a=(0,c.getDataEnum)(i,`align`,l)??(0,c.getDataEnum)(t,`align`,l)??(0,c.getDataEnum)(e,`align`,l)??`start`;E.set(n,{item:t,trigger:r,content:i,index:D++,align:a});let s=o(n),u=(0,c.ensureId)(r,`nav-menu-trigger-${s}`),d=(0,c.ensureId)(i,`nav-menu-content-${s}`);r.setAttribute(`aria-haspopup`,`true`),r.setAttribute(`aria-controls`,d),i.setAttribute(`aria-labelledby`,u)}});let O=Array.from(E.values()).map(e=>e.trigger),k=new Map;for(let[e,t]of E)k.set(t.trigger,e);let A=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,j=e=>Array.from(e.querySelectorAll(A)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),M=()=>{_&&(clearTimeout(_),_=null),v&&(clearTimeout(v),v=null)},N=null,P=()=>(N||(N=document.createElement(`div`),N.setAttribute(`data-slot`,`navigation-menu-bridge`),N.style.cssText=`position: absolute; left: 0; right: 0; top: 0; pointer-events: auto; z-index: -1;`,f&&f.insertBefore(N,f.firstChild),C.push((0,c.on)(N,`pointerenter`,()=>{M()}))),N),F=(t,n,r)=>{f&&requestAnimationFrame(()=>{let i=t.firstElementChild,a=i?.getBoundingClientRect(),o=i?getComputedStyle(i):null,s=o&&parseFloat(o.marginTop)||0,c=o&&parseFloat(o.marginBottom)||0,l=a??t.getBoundingClientRect(),u=l.height+s+c,d=getComputedStyle(f),p=parseFloat(d.marginTop)||0,m=t.getBoundingClientRect();f.style.setProperty(`--viewport-width`,`${m.width}px`),f.style.setProperty(`--viewport-height`,`${u}px`);let h=e.getBoundingClientRect(),g=n.getBoundingClientRect(),_;_=r===`center`?g.left-h.left+g.width/2-l.width/2:r===`end`?g.right-h.left-l.width:g.left-h.left,f.style.setProperty(`--viewport-left`,`${_}px`),f.style.left=`${_}px`,t.style.left=`${_}px`;let v=s+p;if(v>0){let e=P();e.style.height=`${v}px`,e.style.transform=`translateY(-${v}px)`}else N&&(N.style.height=`0`)})},I=e=>g===-1||e>g?`right`:`left`,L=e=>{if(!p)return;if(y=e,!e){p.setAttribute(`data-state`,`hidden`);return}let t=u.getBoundingClientRect(),n=e.getBoundingClientRect();p.style.setProperty(`--indicator-left`,`${n.left-t.left}px`),p.style.setProperty(`--indicator-width`,`${n.width}px`),p.style.setProperty(`--indicator-top`,`${n.top-t.top}px`);let r=f&&parseFloat(getComputedStyle(f).marginTop)||0,i=r<1?1:0;p.style.setProperty(`--indicator-height`,`${n.height-i}px`),p.setAttribute(`data-state`,`visible`)},R=(t,i=!1)=>{if(t===m){M();return}if(t!==null&&t===h){M();return}M(),h=t===null?null:t;let o=()=>{let n=m,r=t?E.get(t):null,i=n!==null&&t!==null&&n!==t,o=i&&r?I(r.index):null,l=document.activeElement;if(t===null&&l&&e.contains(l)){let e=n?E.get(n)?.trigger:null;e&&e.focus()}if(E.forEach(({trigger:e,content:r,item:i},a)=>{let l=a===t,u=a===n;if((0,c.setAria)(e,`expanded`,l),e.setAttribute(`data-state`,l?`open`:`closed`),l||u&&t===null?e.tabIndex=0:e.tabIndex=-1,i.setAttribute(`data-state`,l?`open`:`closed`),!l)if(r.setAttribute(`data-state`,`inactive`),r.setAttribute(`aria-hidden`,`true`),s(r,!0),r.hidden=!0,u&&o){let e=o===`right`?`to-left`:`to-right`;r.setAttribute(`data-motion`,e)}else r.removeAttribute(`data-motion`)}),r){if(o){let e=o===`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`),s(r.content,!1),r.content.hidden=!1,g=r.index,F(r.content,r.trigger,r.align),T(r),L(r.trigger)}else T(null);let u=t!==null;e.setAttribute(`data-state`,u?`open`:`closed`),o?e.setAttribute(`data-motion`,o===`right`?`from-right`:`from-left`):e.removeAttribute(`data-motion`),f&&(f.setAttribute(`data-state`,u?`open`:`closed`),u&&!i?f.setAttribute(`data-instant`,``):i&&f.removeAttribute(`data-instant`),o&&f.style.setProperty(`--motion-direction`,o===`right`?`1`:`-1`)),m=t,h=null,t===null&&L(null),(0,c.emit)(e,`navigation-menu:change`,{value:t}),a?.(t)};i?o():t!==null&&m===null?_=setTimeout(o,n):t!==null&&m!==null?o():v=setTimeout(o,r)};e.setAttribute(`data-state`,`closed`),f&&f.setAttribute(`data-state`,`closed`),p&&p.setAttribute(`data-state`,`hidden`),E.forEach(({trigger:e,content:t,item:n})=>{e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&(e.type=`button`),(0,c.setAria)(e,`expanded`,!1),e.setAttribute(`data-state`,`closed`),e.tabIndex=e===O[0]?0:-1,n.setAttribute(`data-state`,`closed`),t.setAttribute(`data-state`,`inactive`),t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,s(t,!0),t.hidden=!0}),E.forEach(({item:e,trigger:t},n)=>{C.push((0,c.on)(t,`pointerenter`,()=>{b||L(t)})),C.push((0,c.on)(e,`pointerenter`,()=>{b||R(n)})),C.push((0,c.on)(e,`pointerleave`,()=>{h===n&&m===null&&(M(),h=null)})),C.push((0,c.on)(t,`focus`,()=>{x||(i&&R(n,!0),L(t))})),C.push((0,c.on)(t,`pointerdown`,()=>{x=!0})),C.push((0,c.on)(t,`click`,()=>{M(),m===n&&b?(b=!1,R(null,!0),L(null)):m===n&&!b?(b=!0,L(t)):(b=!0,R(n,!0),L(t)),x=!1}))}),C.push((0,c.on)(e,`pointerenter`,()=>{S=!0}),(0,c.on)(e,`pointerleave`,()=>{S=!1,b||(R(null),L(null))}),(0,c.on)(e,`pointerdown`,M)),f&&C.push((0,c.on)(f,`pointerenter`,()=>{M()}),(0,c.on)(f,`transitionend`,e=>{if(e.target!==f)return;let t=m?E.get(m):null;t&&F(t.content,t.trigger,t.align)})),E.forEach(({content:e})=>{C.push((0,c.on)(e,`pointerenter`,()=>{M()}))}),C.push((0,c.on)(u,`keydown`,e=>{let t=e.target,n=O.indexOf(t);if(n===-1)return;let r=k.get(t)??null,i=n;switch(e.key){case`ArrowLeft`:i=n-1,i<0&&(i=O.length-1);break;case`ArrowRight`:i=n+1,i>=O.length&&(i=0);break;case`ArrowDown`:e.preventDefault(),r&&(b=!0,R(r,!0),requestAnimationFrame(()=>{let e=E.get(r);if(!e)return;let t=j(e.content),n=t[0];n?n.focus():e.content.focus()}));return;case`Home`:i=0;break;case`End`:i=O.length-1;break;case`Escape`:b=!1,R(null,!0),L(null);return;default:return}e.preventDefault();let a=O[i];a&&(O.forEach(e=>e.tabIndex=e===a?0:-1),a.focus(),L(a))})),E.forEach(({content:e,trigger:t})=>{C.push((0,c.on)(e,`keydown`,n=>{let r=n.target,i=j(e),a=i.indexOf(r);if(a!==-1)switch(n.key){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(),b=!1,R(null,!0),L(null),t.focus();break}}))});let z=()=>e.contains(document.activeElement)||S||b,B=()=>{b=!1,R(null,!0),L(null)};C.push((0,c.on)(document,`pointerup`,()=>{x=!1},{capture:!0}),(0,c.on)(document,`pointercancel`,()=>{x=!1},{capture:!0})),C.push((0,c.on)(document,`focusin`,t=>{m!==null&&(e.contains(t.target)||B())})),C.push((0,c.createDismissLayer)({root:e,isOpen:()=>m!==null&&z(),onDismiss:B,closeOnClickOutside:!0,closeOnEscape:!0,preventEscapeDefault:!1,isInside:t=>!!t&&e.contains(t)})),C.push((0,c.on)(window,`resize`,()=>{y&&requestAnimationFrame(()=>L(y))}),(0,c.on)(u,`scroll`,()=>{y&&requestAnimationFrame(()=>L(y))})),C.push((0,c.on)(e,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)B();else if(E.has(t.value)){b=!0,R(t.value,!0);let e=E.get(t.value);e&&L(e.trigger)}}}));let V={get value(){return m},open:e=>R(e,!0),close:()=>R(null,!0),destroy:()=>{M(),C.forEach(e=>e()),C.length=0}};return V}const d=new WeakSet;function f(e=document){let t=[];for(let n of(0,c.getRoots)(e,`navigation-menu`)){if(d.has(n))continue;d.add(n),t.push(u(n))}return t}exports.create=f,exports.createNavigationMenu=u;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const e=(e,t)=>e.querySelector(`[data-slot="${t}"]`),t=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],n=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],r=new WeakMap;function i(e,t,n){if(typeof process<`u`&&process.env?.NODE_ENV===`production`)return;let i=r.get(e);i||(i=new Set,r.set(e,i)),!i.has(t)&&(i.add(t),console.warn(`[@data-slot] ${n}`))}function a(e){let t=`data-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`,n=`data-${e}`;return t===n?[t]:[t,n]}function o(e,t){for(let n of a(t))if(e.hasAttribute(n))return e.getAttribute(n);return null}function s(e,t){return a(t).some(t=>e.hasAttribute(t))}const c=new Set([``,`true`,`1`,`yes`]),l=new Set([`false`,`0`,`no`]);function u(e,t){if(!s(e,t))return;let n=o(e,t);if(n===null)return;let r=n.toLowerCase();if(c.has(r))return!0;if(l.has(r))return!1;i(e,t,`Invalid boolean value "${n}" for data-${t}. Expected: true/false/1/0/yes/no or empty.`)}function d(e,t){let n=o(e,t);if(n===null||n===``)return;let r=Number(n);if(Number.isNaN(r)||!Number.isFinite(r)){i(e,t,`Invalid number value "${n}" for data-${t}.`);return}return r}function f(e,t,n){let r=o(e,t);if(r!==null){if(n.includes(r))return r;i(e,t,`Invalid value "${r}" for data-${t}. Expected one of: ${n.join(`, `)}.`)}}const p=Symbol.for(`data-slot.portal-owner`);let m=0;const h=(e,t)=>e.id||=`${t}-${++m}`,g=(e,t,n)=>{n===null?e.removeAttribute(`aria-${t}`):e.setAttribute(`aria-${t}`,String(n))};function _(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const v=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n})),y=[`start`,`center`,`end`];function b(n,r={}){let i=r.delayOpen??d(n,`delayOpen`)??200,a=r.delayClose??d(n,`delayClose`)??150,o=r.openOnFocus??u(n,`openOnFocus`)??!0,s=r.onValueChange,c=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),l=(e,t)=>{`inert`in e&&(e.inert=t)},p=e(n,`navigation-menu-list`),m=t(n,`navigation-menu-item`),b=e(n,`navigation-menu-viewport`),x=e(n,`navigation-menu-indicator`);if(!p||m.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let S=null,C=null,w=-1,T=null,E=null,D=null,O=!1,k=!1,A=!1,j=[],M=null,N=e=>{M?.disconnect(),M=null,!(!b||!e)&&(M=new ResizeObserver(()=>U(e.content,e.trigger,e.align)),M.observe(e.content))};j.push(()=>M?.disconnect());let P=new Map,F=0;m.forEach(t=>{let r=t.dataset.value;if(!r)return;let i=e(t,`navigation-menu-trigger`),a=e(t,`navigation-menu-content`);if(i&&a){let e=f(a,`align`,y)??f(t,`align`,y)??f(n,`align`,y)??`start`;P.set(r,{item:t,trigger:i,content:a,index:F++,align:e});let o=c(r),s=h(i,`nav-menu-trigger-${o}`),l=h(a,`nav-menu-content-${o}`);i.setAttribute(`aria-haspopup`,`true`),i.setAttribute(`aria-controls`,l),a.setAttribute(`aria-labelledby`,s)}});let I=Array.from(P.values()).map(e=>e.trigger),L=new Map;for(let[e,t]of P)L.set(t.trigger,e);let R=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,z=e=>Array.from(e.querySelectorAll(R)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),B=()=>{T&&(clearTimeout(T),T=null),E&&(clearTimeout(E),E=null)},V=null,H=()=>(V||(V=document.createElement(`div`),V.setAttribute(`data-slot`,`navigation-menu-bridge`),V.style.cssText=`position: absolute; left: 0; right: 0; top: 0; pointer-events: auto; z-index: -1;`,b&&b.insertBefore(V,b.firstChild),j.push(_(V,`pointerenter`,()=>{B()}))),V),U=(e,t,r)=>{b&&requestAnimationFrame(()=>{let i=e.firstElementChild,a=i?.getBoundingClientRect(),o=i?getComputedStyle(i):null,s=o&&parseFloat(o.marginTop)||0,c=o&&parseFloat(o.marginBottom)||0,l=a??e.getBoundingClientRect(),u=l.height+s+c,d=getComputedStyle(b),f=parseFloat(d.marginTop)||0,p=e.getBoundingClientRect();b.style.setProperty(`--viewport-width`,`${p.width}px`),b.style.setProperty(`--viewport-height`,`${u}px`);let m=n.getBoundingClientRect(),h=t.getBoundingClientRect(),g;g=r===`center`?h.left-m.left+h.width/2-l.width/2:r===`end`?h.right-m.left-l.width:h.left-m.left,b.style.setProperty(`--viewport-left`,`${g}px`),b.style.left=`${g}px`,e.style.left=`${g}px`;let _=s+f;if(_>0){let e=H();e.style.height=`${_}px`,e.style.transform=`translateY(-${_}px)`}else V&&(V.style.height=`0`)})},W=e=>w===-1||e>w?`right`:`left`,G=e=>{if(!x)return;if(D=e,!e){x.setAttribute(`data-state`,`hidden`);return}let t=p.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,i=r<1?1:0;x.style.setProperty(`--indicator-height`,`${n.height-i}px`),x.setAttribute(`data-state`,`visible`)},K=(e,t=!1)=>{if(e===S){B();return}if(e!==null&&e===C){B();return}B(),C=e===null?null:e;let r=()=>{let t=S,r=e?P.get(e):null,i=t!==null&&e!==null&&t!==e,a=i&&r?W(r.index):null,o=document.activeElement;if(e===null&&o&&n.contains(o)){let e=t?P.get(t)?.trigger:null;e&&e.focus()}if(P.forEach(({trigger:n,content:r,item:i},o)=>{let s=o===e,c=o===t;if(g(n,`expanded`,s),n.setAttribute(`data-state`,s?`open`:`closed`),s||c&&e===null?n.tabIndex=0:n.tabIndex=-1,i.setAttribute(`data-state`,s?`open`:`closed`),!s)if(r.setAttribute(`data-state`,`inactive`),r.setAttribute(`aria-hidden`,`true`),l(r,!0),r.hidden=!0,c&&a){let e=a===`right`?`to-left`:`to-right`;r.setAttribute(`data-motion`,e)}else r.removeAttribute(`data-motion`)}),r){if(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`),l(r.content,!1),r.content.hidden=!1,w=r.index,U(r.content,r.trigger,r.align),N(r),G(r.trigger)}else N(null);let c=e!==null;n.setAttribute(`data-state`,c?`open`:`closed`),a?n.setAttribute(`data-motion`,a===`right`?`from-right`:`from-left`):n.removeAttribute(`data-motion`),b&&(b.setAttribute(`data-state`,c?`open`:`closed`),c&&!i?b.setAttribute(`data-instant`,``):i&&b.removeAttribute(`data-instant`),a&&b.style.setProperty(`--motion-direction`,a===`right`?`1`:`-1`)),S=e,C=null,e===null&&G(null),v(n,`navigation-menu:change`,{value:e}),s?.(e)};t?r():e!==null&&S===null?T=setTimeout(r,i):e!==null&&S!==null?r():E=setTimeout(r,a)};n.setAttribute(`data-state`,`closed`),b&&b.setAttribute(`data-state`,`closed`),x&&x.setAttribute(`data-state`,`hidden`),P.forEach(({trigger:e,content:t,item:n})=>{e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&(e.type=`button`),g(e,`expanded`,!1),e.setAttribute(`data-state`,`closed`),e.tabIndex=e===I[0]?0:-1,n.setAttribute(`data-state`,`closed`),t.setAttribute(`data-state`,`inactive`),t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,l(t,!0),t.hidden=!0}),P.forEach(({item:e,trigger:t},n)=>{j.push(_(t,`pointerenter`,()=>{O||G(t)})),j.push(_(e,`pointerenter`,()=>{O||K(n)})),j.push(_(e,`pointerleave`,()=>{C===n&&S===null&&(B(),C=null)})),j.push(_(t,`focus`,()=>{k||(o&&K(n,!0),G(t))})),j.push(_(t,`pointerdown`,()=>{k=!0})),j.push(_(t,`click`,()=>{B(),S===n&&O?(O=!1,K(null,!0),G(null)):S===n&&!O?(O=!0,G(t)):(O=!0,K(n,!0),G(t)),k=!1}))}),j.push(_(n,`pointerenter`,()=>{A=!0}),_(n,`pointerleave`,()=>{A=!1,O||(K(null),G(null))}),_(n,`pointerdown`,B)),b&&j.push(_(b,`pointerenter`,()=>{B()}),_(b,`transitionend`,e=>{if(e.target!==b)return;let t=S?P.get(S):null;t&&U(t.content,t.trigger,t.align)})),P.forEach(({content:e})=>{j.push(_(e,`pointerenter`,()=>{B()}))}),j.push(_(p,`keydown`,e=>{let t=e.target,n=I.indexOf(t);if(n===-1)return;let r=L.get(t)??null,i=n;switch(e.key){case`ArrowLeft`:i=n-1,i<0&&(i=I.length-1);break;case`ArrowRight`:i=n+1,i>=I.length&&(i=0);break;case`ArrowDown`:e.preventDefault(),r&&(O=!0,K(r,!0),requestAnimationFrame(()=>{let e=P.get(r);if(!e)return;let t=z(e.content),n=t[0];n?n.focus():e.content.focus()}));return;case`Home`:i=0;break;case`End`:i=I.length-1;break;case`Escape`:O=!1,K(null,!0),G(null);return;default:return}e.preventDefault();let a=I[i];a&&(I.forEach(e=>e.tabIndex=e===a?0:-1),a.focus(),G(a))})),P.forEach(({content:e,trigger:t})=>{j.push(_(e,`keydown`,n=>{let r=n.target,i=z(e),a=i.indexOf(r);if(a!==-1)switch(n.key){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(),O=!1,K(null,!0),G(null),t.focus();break}}))});let q=()=>n.contains(document.activeElement)||A||O;j.push(_(document,`pointerup`,()=>{k=!1},{capture:!0}),_(document,`pointercancel`,()=>{k=!1},{capture:!0})),j.push(_(document,`focusin`,e=>{S!==null&&(n.contains(e.target)||(O=!1,K(null,!0),G(null)))})),j.push(_(document,`pointerdown`,e=>{S!==null&&q()&&(n.contains(e.target)||(O=!1,K(null,!0),G(null)))})),j.push(_(document,`keydown`,e=>{e.key!==`Escape`||S===null||q()&&(O=!1,K(null,!0),G(null))})),j.push(_(window,`resize`,()=>{D&&requestAnimationFrame(()=>G(D))}),_(p,`scroll`,()=>{D&&requestAnimationFrame(()=>G(D))})),j.push(_(n,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)O=!1,K(null,!0),G(null);else if(P.has(t.value)){O=!0,K(t.value,!0);let e=P.get(t.value);e&&G(e.trigger)}}}));let J={get value(){return S},open:e=>K(e,!0),close:()=>K(null,!0),destroy:()=>{B(),j.forEach(e=>e()),j.length=0}};return J}const x=new WeakSet;function S(e=document){let t=[];for(let r of n(e,`navigation-menu`)){if(x.has(r))continue;x.add(r),t.push(b(r))}return t}export{S as create,b as createNavigationMenu};
1
+ import{createDismissLayer as e,emit as t,ensureId as n,getDataBool as r,getDataEnum as i,getDataNumber as a,getPart as o,getParts as s,getRoots as c,on as l,setAria as u}from"@data-slot/core";const d=[`start`,`center`,`end`];function f(c,f={}){let p=f.delayOpen??a(c,`delayOpen`)??200,m=f.delayClose??a(c,`delayClose`)??150,h=f.openOnFocus??r(c,`openOnFocus`)??!0,g=f.onValueChange,_=e=>e.replace(/[^a-z0-9\-_:.]/gi,`-`),v=(e,t)=>{`inert`in e&&(e.inert=t)},y=o(c,`navigation-menu-list`),b=s(c,`navigation-menu-item`),x=o(c,`navigation-menu-viewport`),S=o(c,`navigation-menu-indicator`);if(!y||b.length===0)throw Error(`NavigationMenu requires navigation-menu-list and at least one navigation-menu-item`);let C=null,w=null,T=-1,E=null,D=null,O=null,k=!1,A=!1,j=!1,M=[],N=null,P=e=>{N?.disconnect(),N=null,!(!x||!e)&&(N=new ResizeObserver(()=>W(e.content,e.trigger,e.align)),N.observe(e.content))};M.push(()=>N?.disconnect());let F=new Map,I=0;b.forEach(e=>{let t=e.dataset.value;if(!t)return;let r=o(e,`navigation-menu-trigger`),a=o(e,`navigation-menu-content`);if(r&&a){let o=i(a,`align`,d)??i(e,`align`,d)??i(c,`align`,d)??`start`;F.set(t,{item:e,trigger:r,content:a,index:I++,align:o});let s=_(t),l=n(r,`nav-menu-trigger-${s}`),u=n(a,`nav-menu-content-${s}`);r.setAttribute(`aria-haspopup`,`true`),r.setAttribute(`aria-controls`,u),a.setAttribute(`aria-labelledby`,l)}});let L=Array.from(F.values()).map(e=>e.trigger),R=new Map;for(let[e,t]of F)R.set(t.trigger,e);let z=`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])`,B=e=>Array.from(e.querySelectorAll(z)).filter(e=>!e.hidden&&!e.closest(`[hidden]`)),V=()=>{E&&(clearTimeout(E),E=null),D&&(clearTimeout(D),D=null)},H=null,U=()=>(H||(H=document.createElement(`div`),H.setAttribute(`data-slot`,`navigation-menu-bridge`),H.style.cssText=`position: absolute; left: 0; right: 0; top: 0; pointer-events: auto; z-index: -1;`,x&&x.insertBefore(H,x.firstChild),M.push(l(H,`pointerenter`,()=>{V()}))),H),W=(e,t,n)=>{x&&requestAnimationFrame(()=>{let r=e.firstElementChild,i=r?.getBoundingClientRect(),a=r?getComputedStyle(r):null,o=a&&parseFloat(a.marginTop)||0,s=a&&parseFloat(a.marginBottom)||0,l=i??e.getBoundingClientRect(),u=l.height+o+s,d=getComputedStyle(x),f=parseFloat(d.marginTop)||0,p=e.getBoundingClientRect();x.style.setProperty(`--viewport-width`,`${p.width}px`),x.style.setProperty(`--viewport-height`,`${u}px`);let m=c.getBoundingClientRect(),h=t.getBoundingClientRect(),g;g=n===`center`?h.left-m.left+h.width/2-l.width/2:n===`end`?h.right-m.left-l.width:h.left-m.left,x.style.setProperty(`--viewport-left`,`${g}px`),x.style.left=`${g}px`,e.style.left=`${g}px`;let _=o+f;if(_>0){let e=U();e.style.height=`${_}px`,e.style.transform=`translateY(-${_}px)`}else H&&(H.style.height=`0`)})},G=e=>T===-1||e>T?`right`:`left`,K=e=>{if(!S)return;if(O=e,!e){S.setAttribute(`data-state`,`hidden`);return}let t=y.getBoundingClientRect(),n=e.getBoundingClientRect();S.style.setProperty(`--indicator-left`,`${n.left-t.left}px`),S.style.setProperty(`--indicator-width`,`${n.width}px`),S.style.setProperty(`--indicator-top`,`${n.top-t.top}px`);let r=x&&parseFloat(getComputedStyle(x).marginTop)||0,i=r<1?1:0;S.style.setProperty(`--indicator-height`,`${n.height-i}px`),S.setAttribute(`data-state`,`visible`)},q=(e,n=!1)=>{if(e===C){V();return}if(e!==null&&e===w){V();return}V(),w=e===null?null:e;let r=()=>{let n=C,r=e?F.get(e):null,i=n!==null&&e!==null&&n!==e,a=i&&r?G(r.index):null,o=document.activeElement;if(e===null&&o&&c.contains(o)){let e=n?F.get(n)?.trigger:null;e&&e.focus()}if(F.forEach(({trigger:t,content:r,item:i},o)=>{let s=o===e,c=o===n;if(u(t,`expanded`,s),t.setAttribute(`data-state`,s?`open`:`closed`),s||c&&e===null?t.tabIndex=0:t.tabIndex=-1,i.setAttribute(`data-state`,s?`open`:`closed`),!s)if(r.setAttribute(`data-state`,`inactive`),r.setAttribute(`aria-hidden`,`true`),v(r,!0),r.hidden=!0,c&&a){let e=a===`right`?`to-left`:`to-right`;r.setAttribute(`data-motion`,e)}else r.removeAttribute(`data-motion`)}),r){if(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`),v(r.content,!1),r.content.hidden=!1,T=r.index,W(r.content,r.trigger,r.align),P(r),K(r.trigger)}else P(null);let s=e!==null;c.setAttribute(`data-state`,s?`open`:`closed`),a?c.setAttribute(`data-motion`,a===`right`?`from-right`:`from-left`):c.removeAttribute(`data-motion`),x&&(x.setAttribute(`data-state`,s?`open`:`closed`),s&&!i?x.setAttribute(`data-instant`,``):i&&x.removeAttribute(`data-instant`),a&&x.style.setProperty(`--motion-direction`,a===`right`?`1`:`-1`)),C=e,w=null,e===null&&K(null),t(c,`navigation-menu:change`,{value:e}),g?.(e)};n?r():e!==null&&C===null?E=setTimeout(r,p):e!==null&&C!==null?r():D=setTimeout(r,m)};c.setAttribute(`data-state`,`closed`),x&&x.setAttribute(`data-state`,`closed`),S&&S.setAttribute(`data-state`,`hidden`),F.forEach(({trigger:e,content:t,item:n})=>{e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&(e.type=`button`),u(e,`expanded`,!1),e.setAttribute(`data-state`,`closed`),e.tabIndex=e===L[0]?0:-1,n.setAttribute(`data-state`,`closed`),t.setAttribute(`data-state`,`inactive`),t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,v(t,!0),t.hidden=!0}),F.forEach(({item:e,trigger:t},n)=>{M.push(l(t,`pointerenter`,()=>{k||K(t)})),M.push(l(e,`pointerenter`,()=>{k||q(n)})),M.push(l(e,`pointerleave`,()=>{w===n&&C===null&&(V(),w=null)})),M.push(l(t,`focus`,()=>{A||(h&&q(n,!0),K(t))})),M.push(l(t,`pointerdown`,()=>{A=!0})),M.push(l(t,`click`,()=>{V(),C===n&&k?(k=!1,q(null,!0),K(null)):C===n&&!k?(k=!0,K(t)):(k=!0,q(n,!0),K(t)),A=!1}))}),M.push(l(c,`pointerenter`,()=>{j=!0}),l(c,`pointerleave`,()=>{j=!1,k||(q(null),K(null))}),l(c,`pointerdown`,V)),x&&M.push(l(x,`pointerenter`,()=>{V()}),l(x,`transitionend`,e=>{if(e.target!==x)return;let t=C?F.get(C):null;t&&W(t.content,t.trigger,t.align)})),F.forEach(({content:e})=>{M.push(l(e,`pointerenter`,()=>{V()}))}),M.push(l(y,`keydown`,e=>{let t=e.target,n=L.indexOf(t);if(n===-1)return;let r=R.get(t)??null,i=n;switch(e.key){case`ArrowLeft`:i=n-1,i<0&&(i=L.length-1);break;case`ArrowRight`:i=n+1,i>=L.length&&(i=0);break;case`ArrowDown`:e.preventDefault(),r&&(k=!0,q(r,!0),requestAnimationFrame(()=>{let e=F.get(r);if(!e)return;let t=B(e.content),n=t[0];n?n.focus():e.content.focus()}));return;case`Home`:i=0;break;case`End`:i=L.length-1;break;case`Escape`:k=!1,q(null,!0),K(null);return;default:return}e.preventDefault();let a=L[i];a&&(L.forEach(e=>e.tabIndex=e===a?0:-1),a.focus(),K(a))})),F.forEach(({content:e,trigger:t})=>{M.push(l(e,`keydown`,n=>{let r=n.target,i=B(e),a=i.indexOf(r);if(a!==-1)switch(n.key){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(),k=!1,q(null,!0),K(null),t.focus();break}}))});let J=()=>c.contains(document.activeElement)||j||k,Y=()=>{k=!1,q(null,!0),K(null)};M.push(l(document,`pointerup`,()=>{A=!1},{capture:!0}),l(document,`pointercancel`,()=>{A=!1},{capture:!0})),M.push(l(document,`focusin`,e=>{C!==null&&(c.contains(e.target)||Y())})),M.push(e({root:c,isOpen:()=>C!==null&&J(),onDismiss:Y,closeOnClickOutside:!0,closeOnEscape:!0,preventEscapeDefault:!1,isInside:e=>!!e&&c.contains(e)})),M.push(l(window,`resize`,()=>{O&&requestAnimationFrame(()=>K(O))}),l(y,`scroll`,()=>{O&&requestAnimationFrame(()=>K(O))})),M.push(l(c,`navigation-menu:set`,e=>{let t=e.detail;if(t?.value!==void 0){if(t.value===null)Y();else if(F.has(t.value)){k=!0,q(t.value,!0);let e=F.get(t.value);e&&K(e.trigger)}}}));let X={get value(){return C},open:e=>q(e,!0),close:()=>q(null,!0),destroy:()=>{V(),M.forEach(e=>e()),M.length=0}};return X}const p=new WeakSet;function m(e=document){let t=[];for(let n of c(e,`navigation-menu`)){if(p.has(n))continue;p.add(n),t.push(f(n))}return t}export{m as create,f as createNavigationMenu};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-slot/navigation-menu",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.cjs",
@@ -24,9 +24,6 @@
24
24
  "scripts": {
25
25
  "build": "tsdown"
26
26
  },
27
- "devDependencies": {
28
- "@data-slot/core": "workspace:*"
29
- },
30
27
  "repository": {
31
28
  "type": "git",
32
29
  "url": "https://github.com/bejamas/data-slot",
@@ -40,5 +37,8 @@
40
37
  "vanilla",
41
38
  "data-slot"
42
39
  ],
43
- "license": "MIT"
40
+ "license": "MIT",
41
+ "dependencies": {
42
+ "@data-slot/core": "workspace:*"
43
+ }
44
44
  }