@data-slot/popover 0.2.123 → 0.2.125

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
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=[`top`,`right`,`bottom`,`left`],n=[`start`,`center`,`end`];function r(r,i={}){let a=(0,e.getPart)(r,`popover-trigger`),o=(0,e.getPart)(r,`popover-content`),s=(0,e.getPart)(r,`popover-close`),c=(0,e.getPart)(r,`popover-positioner`),l=c&&o&&c.contains(o)?c:null,u=(0,e.getPart)(r,`popover-portal`),d=u&&l&&u.contains(l)?u:null;if(!a||!o)throw Error(`Popover requires trigger and content slots`);let f=i.defaultOpen??(0,e.getDataBool)(r,`defaultOpen`)??!1,p=i.onOpenChange,m=i.closeOnClickOutside??(0,e.getDataBool)(r,`closeOnClickOutside`)??!0,h=i.closeOnEscape??(0,e.getDataBool)(r,`closeOnEscape`)??!0,g=i.portal??(0,e.getDataBool)(o,`portal`)??(0,e.getDataBool)(r,`portal`)??!0,_=(t,n)=>(0,e.getDataEnum)(o,t,n)??(l?(0,e.getDataEnum)(l,t,n):void 0)??(0,e.getDataEnum)(r,t,n),v=t=>(0,e.getDataNumber)(o,t)??(l?(0,e.getDataNumber)(l,t):void 0)??(0,e.getDataNumber)(r,t),y=t=>(0,e.getDataBool)(o,t)??(l?(0,e.getDataBool)(l,t):void 0)??(0,e.getDataBool)(r,t),b=i.position??_(`position`,t),x=i.side??_(`side`,t)??b??`bottom`,S=i.align??_(`align`,n)??`center`,C=i.sideOffset??v(`sideOffset`)??4,w=i.alignOffset??v(`alignOffset`)??0,T=i.avoidCollisions??y(`avoidCollisions`)??!0,E=i.collisionPadding??v(`collisionPadding`)??8,D=f,O=[],k=(0,e.createPortalLifecycle)({content:o,root:r,enabled:g,wrapperSlot:l?void 0:`popover-positioner`,container:l??void 0,mountTarget:l?d??l:void 0}),A=!1,j=null,M=!1,N=()=>{M&&=(o.removeAttribute(`tabindex`),!1)},P=()=>{let e=o.querySelector(`[autofocus]`);if(e)return e.focus();let t=o.querySelector(`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`);if(t)return t.focus();o.getAttribute(`tabindex`)||(o.setAttribute(`tabindex`,`-1`),M=!0),o.focus()},F=(0,e.ensureId)(o,`popover-content`);a.setAttribute(`aria-haspopup`,`dialog`),a.setAttribute(`aria-controls`,F),o.setAttribute(`data-side`,x),o.setAttribute(`data-align`,S),o.setAttribute(`data-position`,x);let I=()=>{let t=k.container,n=r.ownerDocument.defaultView??window,i=a.getBoundingClientRect(),s=(0,e.computeFloatingPosition)({anchorRect:i,contentRect:(0,e.measurePopupContentRect)(o),side:x,align:S,sideOffset:C,alignOffset:w,avoidCollisions:T,collisionPadding:E}),c=(0,e.computeFloatingTransformOrigin)({side:s.side,align:s.align,anchorRect:i,popupX:s.x,popupY:s.y});t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.transform=`translate3d(${s.x+n.scrollX}px, ${s.y+n.scrollY}px, 0)`,t.style.setProperty(`--transform-origin`,c),t.style.willChange=`transform`,t.style.margin=`0`,o.setAttribute(`data-side`,s.side),o.setAttribute(`data-align`,s.align),t!==o&&(t.setAttribute(`data-side`,s.side),t.setAttribute(`data-align`,s.align)),o.setAttribute(`data-position`,s.side)},L=e=>{let t=k.container;r.setAttribute(`data-state`,e),o.setAttribute(`data-state`,e),t!==o&&t.setAttribute(`data-state`,e),e===`open`?(r.setAttribute(`data-open`,``),o.setAttribute(`data-open`,``),t!==o&&t.setAttribute(`data-open`,``),r.removeAttribute(`data-closed`),o.removeAttribute(`data-closed`),t!==o&&t.removeAttribute(`data-closed`)):(r.setAttribute(`data-closed`,``),o.setAttribute(`data-closed`,``),t!==o&&t.setAttribute(`data-closed`,``),r.removeAttribute(`data-open`),o.removeAttribute(`data-open`),t!==o&&t.removeAttribute(`data-open`))},R=()=>{requestAnimationFrame(()=>{j&&j.isConnected?(0,e.focusElement)(j):(0,e.focusElement)(a),j=null})},z=(0,e.createPresenceLifecycle)({element:o,onExitComplete:()=>{A||(k.restore(),o.hidden=!0,N(),R())}}),B=(0,e.createPositionSync)({observedElements:[a,o],isActive:()=>D,ancestorScroll:!1,onUpdate:I}),V=t=>{D!==t&&(t&&(j=document.activeElement),D=t,(0,e.setAria)(a,`expanded`,D),t?(k.mount(),o.hidden=!1,L(`open`),z.enter(),I(),B.start(),B.update(),requestAnimationFrame(P)):(L(`closed`),z.exit(),B.stop()),(0,e.emit)(r,`popover:change`,{open:D}),p?.(D))};return(0,e.setAria)(a,`expanded`,D),L(D?`open`:`closed`),o.hidden=!D,f&&(k.mount(),z.enter(),o.hidden=!1,I(),B.start(),B.update(),requestAnimationFrame(P)),O.push((0,e.on)(a,`click`,()=>V(!D))),s&&O.push((0,e.on)(s,`click`,()=>V(!1))),O.push((0,e.createDismissLayer)({root:r,isOpen:()=>D,onDismiss:()=>V(!1),closeOnClickOutside:m,closeOnEscape:h})),O.push((0,e.on)(r,`popover:set`,e=>{let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&V(n)})),{open:()=>V(!0),close:()=>V(!1),toggle:()=>V(!D),get isOpen(){return D},destroy:()=>{A=!0,B.stop(),z.cleanup(),k.cleanup(),O.forEach(e=>e()),O.length=0,N()}}}const i=new WeakSet;function a(t=document){let n=[];for(let a of(0,e.getRoots)(t,`popover`))i.has(a)||(i.add(a),n.push(r(a)));return n}exports.create=a,exports.createPopover=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=[`top`,`right`,`bottom`,`left`],n=[`start`,`center`,`end`],r=`@data-slot/popover`;function i(i,a={}){let o=(0,e.reuseRootBinding)(i,r,`[@data-slot/popover] createPopover() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(o)return o;let s=(0,e.getPart)(i,`popover-trigger`),c=(0,e.getPart)(i,`popover-content`),l=(0,e.getPart)(i,`popover-close`),u=(0,e.getPart)(i,`popover-positioner`),d=u&&c&&u.contains(c)?u:null,f=(0,e.getPart)(i,`popover-portal`),p=f&&d&&f.contains(d)?f:null;if(!s||!c)throw Error(`Popover requires trigger and content slots`);let m=a.defaultOpen??(0,e.getDataBool)(i,`defaultOpen`)??!1,h=a.onOpenChange,g=a.closeOnClickOutside??(0,e.getDataBool)(i,`closeOnClickOutside`)??!0,_=a.closeOnEscape??(0,e.getDataBool)(i,`closeOnEscape`)??!0,v=a.portal??(0,e.getDataBool)(c,`portal`)??(0,e.getDataBool)(i,`portal`)??!0,y=(t,n)=>(0,e.getDataEnum)(c,t,n)??(d?(0,e.getDataEnum)(d,t,n):void 0)??(0,e.getDataEnum)(i,t,n),b=t=>(0,e.getDataNumber)(c,t)??(d?(0,e.getDataNumber)(d,t):void 0)??(0,e.getDataNumber)(i,t),x=t=>(0,e.getDataBool)(c,t)??(d?(0,e.getDataBool)(d,t):void 0)??(0,e.getDataBool)(i,t),S=a.position??y(`position`,t),C=a.side??y(`side`,t)??S??`bottom`,w=a.align??y(`align`,n)??`center`,T=a.sideOffset??b(`sideOffset`)??4,E=a.alignOffset??b(`alignOffset`)??0,D=a.avoidCollisions??x(`avoidCollisions`)??!0,O=a.collisionPadding??b(`collisionPadding`)??8,k=m,A=[],j=(0,e.createPortalLifecycle)({content:c,root:i,enabled:v,wrapperSlot:d?void 0:`popover-positioner`,container:d??void 0,mountTarget:d?p??d:void 0}),M=!1,N=null,P=!1,F=()=>{P&&=(c.removeAttribute(`tabindex`),!1)},I=()=>{let e=c.querySelector(`[autofocus]`);if(e)return e.focus();let t=c.querySelector(`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`);if(t)return t.focus();c.getAttribute(`tabindex`)||(c.setAttribute(`tabindex`,`-1`),P=!0),c.focus()},L=(0,e.ensureId)(c,`popover-content`);s.setAttribute(`aria-haspopup`,`dialog`),s.setAttribute(`aria-controls`,L),c.setAttribute(`data-side`,C),c.setAttribute(`data-align`,w),c.setAttribute(`data-position`,C);let R=()=>{let t=j.container,n=i.ownerDocument.defaultView??window,r=s.getBoundingClientRect(),a=(0,e.computeFloatingPosition)({anchorRect:r,contentRect:(0,e.measurePopupContentRect)(c),side:C,align:w,sideOffset:T,alignOffset:E,avoidCollisions:D,collisionPadding:O}),o=(0,e.computeFloatingTransformOrigin)({side:a.side,align:a.align,anchorRect:r,popupX:a.x,popupY:a.y});t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.transform=`translate3d(${a.x+n.scrollX}px, ${a.y+n.scrollY}px, 0)`,t.style.setProperty(`--transform-origin`,o),t.style.willChange=`transform`,t.style.margin=`0`,c.setAttribute(`data-side`,a.side),c.setAttribute(`data-align`,a.align),t!==c&&(t.setAttribute(`data-side`,a.side),t.setAttribute(`data-align`,a.align)),c.setAttribute(`data-position`,a.side)},z=e=>{let t=j.container;i.setAttribute(`data-state`,e),c.setAttribute(`data-state`,e),t!==c&&t.setAttribute(`data-state`,e),e===`open`?(i.setAttribute(`data-open`,``),c.setAttribute(`data-open`,``),t!==c&&t.setAttribute(`data-open`,``),i.removeAttribute(`data-closed`),c.removeAttribute(`data-closed`),t!==c&&t.removeAttribute(`data-closed`)):(i.setAttribute(`data-closed`,``),c.setAttribute(`data-closed`,``),t!==c&&t.setAttribute(`data-closed`,``),i.removeAttribute(`data-open`),c.removeAttribute(`data-open`),t!==c&&t.removeAttribute(`data-open`))},B=()=>{requestAnimationFrame(()=>{N&&N.isConnected?(0,e.focusElement)(N):(0,e.focusElement)(s),N=null})},V=(0,e.createPresenceLifecycle)({element:c,onExitComplete:()=>{M||(j.restore(),c.hidden=!0,F(),B())}}),H=(0,e.createPositionSync)({observedElements:[s,c],isActive:()=>k,ancestorScroll:!1,onUpdate:R}),U=t=>{k!==t&&(t&&(N=document.activeElement),k=t,(0,e.setAria)(s,`expanded`,k),t?(j.mount(),c.hidden=!1,z(`open`),V.enter(),R(),H.start(),H.update(),requestAnimationFrame(I)):(z(`closed`),V.exit(),H.stop()),(0,e.emit)(i,`popover:change`,{open:k}),h?.(k))};(0,e.setAria)(s,`expanded`,k),z(k?`open`:`closed`),c.hidden=!k,m&&(j.mount(),V.enter(),c.hidden=!1,R(),H.start(),H.update(),requestAnimationFrame(I)),A.push((0,e.on)(s,`click`,()=>U(!k))),l&&A.push((0,e.on)(l,`click`,()=>U(!1))),A.push((0,e.createDismissLayer)({root:i,isOpen:()=>k,onDismiss:()=>U(!1),closeOnClickOutside:g,closeOnEscape:_})),A.push((0,e.on)(i,`popover:set`,e=>{let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&U(n)}));let W={open:()=>U(!0),close:()=>U(!1),toggle:()=>U(!k),get isOpen(){return k},destroy:()=>{M=!0,H.stop(),V.cleanup(),j.cleanup(),A.forEach(e=>e()),A.length=0,F(),(0,e.clearRootBinding)(i,r,W)}};return(0,e.setRootBinding)(i,r,W),W}function a(t=document){let n=[];for(let a of(0,e.getRoots)(t,`popover`))(0,e.hasRootBinding)(a,r)||n.push(i(a));return n}exports.create=a,exports.createPopover=i;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{computeFloatingPosition as e,computeFloatingTransformOrigin as t,createDismissLayer as n,createPortalLifecycle as r,createPositionSync as i,createPresenceLifecycle as a,emit as o,ensureId as s,focusElement as c,getDataBool as l,getDataEnum as u,getDataNumber as d,getPart as f,getRoots as p,measurePopupContentRect as m,on as h,setAria as g}from"@data-slot/core";const _=[`top`,`right`,`bottom`,`left`],v=[`start`,`center`,`end`];function y(p,y={}){let b=f(p,`popover-trigger`),x=f(p,`popover-content`),S=f(p,`popover-close`),C=f(p,`popover-positioner`),w=C&&x&&C.contains(x)?C:null,T=f(p,`popover-portal`),E=T&&w&&T.contains(w)?T:null;if(!b||!x)throw Error(`Popover requires trigger and content slots`);let D=y.defaultOpen??l(p,`defaultOpen`)??!1,ee=y.onOpenChange,te=y.closeOnClickOutside??l(p,`closeOnClickOutside`)??!0,ne=y.closeOnEscape??l(p,`closeOnEscape`)??!0,O=y.portal??l(x,`portal`)??l(p,`portal`)??!0,k=(e,t)=>u(x,e,t)??(w?u(w,e,t):void 0)??u(p,e,t),A=e=>d(x,e)??(w?d(w,e):void 0)??d(p,e),j=e=>l(x,e)??(w?l(w,e):void 0)??l(p,e),M=y.position??k(`position`,_),N=y.side??k(`side`,_)??M??`bottom`,P=y.align??k(`align`,v)??`center`,F=y.sideOffset??A(`sideOffset`)??4,I=y.alignOffset??A(`alignOffset`)??0,L=y.avoidCollisions??j(`avoidCollisions`)??!0,R=y.collisionPadding??A(`collisionPadding`)??8,z=D,B=[],V=r({content:x,root:p,enabled:O,wrapperSlot:w?void 0:`popover-positioner`,container:w??void 0,mountTarget:w?E??w:void 0}),H=!1,U=null,W=!1,G=()=>{W&&=(x.removeAttribute(`tabindex`),!1)},K=()=>{let e=x.querySelector(`[autofocus]`);if(e)return e.focus();let t=x.querySelector(`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`);if(t)return t.focus();x.getAttribute(`tabindex`)||(x.setAttribute(`tabindex`,`-1`),W=!0),x.focus()},q=s(x,`popover-content`);b.setAttribute(`aria-haspopup`,`dialog`),b.setAttribute(`aria-controls`,q),x.setAttribute(`data-side`,N),x.setAttribute(`data-align`,P),x.setAttribute(`data-position`,N);let J=()=>{let n=V.container,r=p.ownerDocument.defaultView??window,i=b.getBoundingClientRect(),a=e({anchorRect:i,contentRect:m(x),side:N,align:P,sideOffset:F,alignOffset:I,avoidCollisions:L,collisionPadding:R}),o=t({side:a.side,align:a.align,anchorRect:i,popupX:a.x,popupY:a.y});n.style.position=`absolute`,n.style.top=`0px`,n.style.left=`0px`,n.style.transform=`translate3d(${a.x+r.scrollX}px, ${a.y+r.scrollY}px, 0)`,n.style.setProperty(`--transform-origin`,o),n.style.willChange=`transform`,n.style.margin=`0`,x.setAttribute(`data-side`,a.side),x.setAttribute(`data-align`,a.align),n!==x&&(n.setAttribute(`data-side`,a.side),n.setAttribute(`data-align`,a.align)),x.setAttribute(`data-position`,a.side)},Y=e=>{let t=V.container;p.setAttribute(`data-state`,e),x.setAttribute(`data-state`,e),t!==x&&t.setAttribute(`data-state`,e),e===`open`?(p.setAttribute(`data-open`,``),x.setAttribute(`data-open`,``),t!==x&&t.setAttribute(`data-open`,``),p.removeAttribute(`data-closed`),x.removeAttribute(`data-closed`),t!==x&&t.removeAttribute(`data-closed`)):(p.setAttribute(`data-closed`,``),x.setAttribute(`data-closed`,``),t!==x&&t.setAttribute(`data-closed`,``),p.removeAttribute(`data-open`),x.removeAttribute(`data-open`),t!==x&&t.removeAttribute(`data-open`))},X=()=>{requestAnimationFrame(()=>{U&&U.isConnected?c(U):c(b),U=null})},Z=a({element:x,onExitComplete:()=>{H||(V.restore(),x.hidden=!0,G(),X())}}),Q=i({observedElements:[b,x],isActive:()=>z,ancestorScroll:!1,onUpdate:J}),$=e=>{z!==e&&(e&&(U=document.activeElement),z=e,g(b,`expanded`,z),e?(V.mount(),x.hidden=!1,Y(`open`),Z.enter(),J(),Q.start(),Q.update(),requestAnimationFrame(K)):(Y(`closed`),Z.exit(),Q.stop()),o(p,`popover:change`,{open:z}),ee?.(z))};return g(b,`expanded`,z),Y(z?`open`:`closed`),x.hidden=!z,D&&(V.mount(),Z.enter(),x.hidden=!1,J(),Q.start(),Q.update(),requestAnimationFrame(K)),B.push(h(b,`click`,()=>$(!z))),S&&B.push(h(S,`click`,()=>$(!1))),B.push(n({root:p,isOpen:()=>z,onDismiss:()=>$(!1),closeOnClickOutside:te,closeOnEscape:ne})),B.push(h(p,`popover:set`,e=>{let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&$(n)})),{open:()=>$(!0),close:()=>$(!1),toggle:()=>$(!z),get isOpen(){return z},destroy:()=>{H=!0,Q.stop(),Z.cleanup(),V.cleanup(),B.forEach(e=>e()),B.length=0,G()}}}const b=new WeakSet;function x(e=document){let t=[];for(let n of p(e,`popover`))b.has(n)||(b.add(n),t.push(y(n)));return t}export{x as create,y as createPopover};
1
+ import{clearRootBinding as e,computeFloatingPosition as t,computeFloatingTransformOrigin as n,createDismissLayer as r,createPortalLifecycle as i,createPositionSync as a,createPresenceLifecycle as o,emit as s,ensureId as c,focusElement as l,getDataBool as u,getDataEnum as d,getDataNumber as f,getPart as p,getRoots as m,hasRootBinding as h,measurePopupContentRect as ee,on as g,reuseRootBinding as te,setAria as _,setRootBinding as ne}from"@data-slot/core";const v=[`top`,`right`,`bottom`,`left`],y=[`start`,`center`,`end`],b=`@data-slot/popover`;function x(m,h={}){let x=te(m,b,`[@data-slot/popover] createPopover() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(x)return x;let S=p(m,`popover-trigger`),C=p(m,`popover-content`),w=p(m,`popover-close`),T=p(m,`popover-positioner`),E=T&&C&&T.contains(C)?T:null,D=p(m,`popover-portal`),re=D&&E&&D.contains(E)?D:null;if(!S||!C)throw Error(`Popover requires trigger and content slots`);let O=h.defaultOpen??u(m,`defaultOpen`)??!1,ie=h.onOpenChange,k=h.closeOnClickOutside??u(m,`closeOnClickOutside`)??!0,A=h.closeOnEscape??u(m,`closeOnEscape`)??!0,j=h.portal??u(C,`portal`)??u(m,`portal`)??!0,M=(e,t)=>d(C,e,t)??(E?d(E,e,t):void 0)??d(m,e,t),N=e=>f(C,e)??(E?f(E,e):void 0)??f(m,e),P=e=>u(C,e)??(E?u(E,e):void 0)??u(m,e),F=h.position??M(`position`,v),I=h.side??M(`side`,v)??F??`bottom`,L=h.align??M(`align`,y)??`center`,R=h.sideOffset??N(`sideOffset`)??4,z=h.alignOffset??N(`alignOffset`)??0,ae=h.avoidCollisions??P(`avoidCollisions`)??!0,oe=h.collisionPadding??N(`collisionPadding`)??8,B=O,V=[],H=i({content:C,root:m,enabled:j,wrapperSlot:E?void 0:`popover-positioner`,container:E??void 0,mountTarget:E?re??E:void 0}),U=!1,W=null,G=!1,K=()=>{G&&=(C.removeAttribute(`tabindex`),!1)},q=()=>{let e=C.querySelector(`[autofocus]`);if(e)return e.focus();let t=C.querySelector(`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`);if(t)return t.focus();C.getAttribute(`tabindex`)||(C.setAttribute(`tabindex`,`-1`),G=!0),C.focus()},se=c(C,`popover-content`);S.setAttribute(`aria-haspopup`,`dialog`),S.setAttribute(`aria-controls`,se),C.setAttribute(`data-side`,I),C.setAttribute(`data-align`,L),C.setAttribute(`data-position`,I);let J=()=>{let e=H.container,r=m.ownerDocument.defaultView??window,i=S.getBoundingClientRect(),a=t({anchorRect:i,contentRect:ee(C),side:I,align:L,sideOffset:R,alignOffset:z,avoidCollisions:ae,collisionPadding:oe}),o=n({side:a.side,align:a.align,anchorRect:i,popupX:a.x,popupY:a.y});e.style.position=`absolute`,e.style.top=`0px`,e.style.left=`0px`,e.style.transform=`translate3d(${a.x+r.scrollX}px, ${a.y+r.scrollY}px, 0)`,e.style.setProperty(`--transform-origin`,o),e.style.willChange=`transform`,e.style.margin=`0`,C.setAttribute(`data-side`,a.side),C.setAttribute(`data-align`,a.align),e!==C&&(e.setAttribute(`data-side`,a.side),e.setAttribute(`data-align`,a.align)),C.setAttribute(`data-position`,a.side)},Y=e=>{let t=H.container;m.setAttribute(`data-state`,e),C.setAttribute(`data-state`,e),t!==C&&t.setAttribute(`data-state`,e),e===`open`?(m.setAttribute(`data-open`,``),C.setAttribute(`data-open`,``),t!==C&&t.setAttribute(`data-open`,``),m.removeAttribute(`data-closed`),C.removeAttribute(`data-closed`),t!==C&&t.removeAttribute(`data-closed`)):(m.setAttribute(`data-closed`,``),C.setAttribute(`data-closed`,``),t!==C&&t.setAttribute(`data-closed`,``),m.removeAttribute(`data-open`),C.removeAttribute(`data-open`),t!==C&&t.removeAttribute(`data-open`))},ce=()=>{requestAnimationFrame(()=>{W&&W.isConnected?l(W):l(S),W=null})},X=o({element:C,onExitComplete:()=>{U||(H.restore(),C.hidden=!0,K(),ce())}}),Z=a({observedElements:[S,C],isActive:()=>B,ancestorScroll:!1,onUpdate:J}),Q=e=>{B!==e&&(e&&(W=document.activeElement),B=e,_(S,`expanded`,B),e?(H.mount(),C.hidden=!1,Y(`open`),X.enter(),J(),Z.start(),Z.update(),requestAnimationFrame(q)):(Y(`closed`),X.exit(),Z.stop()),s(m,`popover:change`,{open:B}),ie?.(B))};_(S,`expanded`,B),Y(B?`open`:`closed`),C.hidden=!B,O&&(H.mount(),X.enter(),C.hidden=!1,J(),Z.start(),Z.update(),requestAnimationFrame(q)),V.push(g(S,`click`,()=>Q(!B))),w&&V.push(g(w,`click`,()=>Q(!1))),V.push(r({root:m,isOpen:()=>B,onDismiss:()=>Q(!1),closeOnClickOutside:k,closeOnEscape:A})),V.push(g(m,`popover:set`,e=>{let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&Q(n)}));let $={open:()=>Q(!0),close:()=>Q(!1),toggle:()=>Q(!B),get isOpen(){return B},destroy:()=>{U=!0,Z.stop(),X.cleanup(),H.cleanup(),V.forEach(e=>e()),V.length=0,K(),e(m,b,$)}};return ne(m,b,$),$}function S(e=document){let t=[];for(let n of m(e,`popover`))h(n,b)||t.push(x(n));return t}export{S as create,x as createPopover};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-slot/popover",
3
- "version": "0.2.123",
3
+ "version": "0.2.125",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.cjs",
@@ -34,6 +34,6 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@data-slot/core": "0.2.123"
37
+ "@data-slot/core": "0.2.125"
38
38
  }
39
39
  }