@data-slot/hover-card 0.2.122 → 0.2.124
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=[`top`,`right`,`bottom`,`left`],n=[`start`,`center`,`end`];let r=0;const i=new Set,a=new Set,o=(e,t)=>{if(!e)return!1;for(let n of i)if(n!==t&&n.contains(e))return!0;return!1},s=(e,t)=>{for(let n of a)n(e,t)}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=[`top`,`right`,`bottom`,`left`],n=[`start`,`center`,`end`];let r=0;const i=new Set,a=new Set,o=(e,t)=>{if(!e)return!1;for(let n of i)if(n!==t&&n.contains(e))return!0;return!1},s=(e,t)=>{for(let n of a)n(e,t)},c=`@data-slot/hover-card`;function l(l,u={}){let d=(0,e.reuseRootBinding)(l,c,`[@data-slot/hover-card] createHoverCard() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(d)return d;let f=(0,e.getPart)(l,`hover-card-trigger`),p=(0,e.getPart)(l,`hover-card-content`),m=(0,e.getPart)(l,`hover-card-positioner`),h=m&&p&&m.contains(p)?m:null,g=(0,e.getPart)(l,`hover-card-portal`),ee=g&&h&&g.contains(h)?g:null;if(!f||!p)throw Error(`Hover-card requires trigger and content slots`);let te=u.open!==void 0,_=u.defaultOpen??(0,e.getDataBool)(l,`defaultOpen`)??!1,v=u.delay??(0,e.getDataNumber)(l,`delay`)??700,y=u.skipDelayDuration??(0,e.getDataNumber)(l,`skipDelayDuration`)??300,b=u.closeDelay??(0,e.getDataNumber)(l,`closeDelay`)??300,ne=u.onOpenChange,re=u.closeOnClickOutside??(0,e.getDataBool)(l,`closeOnClickOutside`)??!0,ie=u.closeOnEscape??(0,e.getDataBool)(l,`closeOnEscape`)??!0,ae=u.portal??(0,e.getDataBool)(p,`portal`)??(0,e.getDataBool)(l,`portal`)??!0,x=(t,n)=>(0,e.getDataEnum)(p,t,n)??(h?(0,e.getDataEnum)(h,t,n):void 0)??(0,e.getDataEnum)(l,t,n),S=t=>(0,e.getDataNumber)(p,t)??(h?(0,e.getDataNumber)(h,t):void 0)??(0,e.getDataNumber)(l,t),C=t=>(0,e.getDataBool)(p,t)??(h?(0,e.getDataBool)(h,t):void 0)??(0,e.getDataBool)(l,t),w=u.side??x(`side`,t)??`bottom`,T=u.align??x(`align`,n)??`center`,oe=u.sideOffset??S(`sideOffset`)??4,se=u.alignOffset??S(`alignOffset`)??0,ce=u.avoidCollisions??C(`avoidCollisions`)??!0,le=u.collisionPadding??S(`collisionPadding`)??8,E=u.open??_,D=!1,O=!1,k=!1,A=!1,j=!1,M=null,N=null,P=-1/0,F=-1/0,I=[],L=(0,e.createPortalLifecycle)({content:p,root:l,enabled:ae,wrapperSlot:h?void 0:`hover-card-positioner`,container:h??void 0,mountTarget:h?ee??h:void 0}),ue=(0,e.ensureId)(p,`hover-card-content`);f.setAttribute(`aria-haspopup`,`dialog`),f.setAttribute(`aria-controls`,ue),p.setAttribute(`data-side`,w),p.setAttribute(`data-align`,T);let R=()=>f.hasAttribute(`disabled`)||f.getAttribute(`aria-disabled`)===`true`,z=()=>{M&&=(clearTimeout(M),null)},B=()=>{N&&=(clearTimeout(N),null)},V=()=>{z(),B()},H=(t,n)=>{(0,e.emit)(l,`hover-card:change`,{open:t,reason:n,trigger:f,content:p}),ne?.(t)},U=()=>{let t=L.container,n=l.ownerDocument.defaultView??window,r=f.getBoundingClientRect(),i=(0,e.computeFloatingPosition)({anchorRect:r,contentRect:(0,e.measurePopupContentRect)(p),side:w,align:T,sideOffset:oe,alignOffset:se,avoidCollisions:ce,collisionPadding:le}),a=(0,e.computeFloatingTransformOrigin)({side:i.side,align:i.align,anchorRect:r,popupX:i.x,popupY:i.y});t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.transform=`translate3d(${i.x+n.scrollX}px, ${i.y+n.scrollY}px, 0)`,t.style.setProperty(`--transform-origin`,a),t.style.willChange=`transform`,t.style.margin=`0`,p.setAttribute(`data-side`,i.side),p.setAttribute(`data-align`,i.align),t!==p&&(t.setAttribute(`data-side`,i.side),t.setAttribute(`data-align`,i.align))},W=e=>{let t=L.container;if(l.setAttribute(`data-state`,e),p.setAttribute(`data-state`,e),t!==p&&t.setAttribute(`data-state`,e),e===`open`){l.setAttribute(`data-open`,``),p.setAttribute(`data-open`,``),t!==p&&t.setAttribute(`data-open`,``),D?(l.setAttribute(`data-instant`,``),p.setAttribute(`data-instant`,``),t!==p&&t.setAttribute(`data-instant`,``)):(l.removeAttribute(`data-instant`),p.removeAttribute(`data-instant`),t!==p&&t.removeAttribute(`data-instant`)),l.removeAttribute(`data-closed`),p.removeAttribute(`data-closed`),t!==p&&t.removeAttribute(`data-closed`);return}l.setAttribute(`data-closed`,``),p.setAttribute(`data-closed`,``),t!==p&&t.setAttribute(`data-closed`,``),D?(l.setAttribute(`data-instant`,``),p.setAttribute(`data-instant`,``),t!==p&&t.setAttribute(`data-instant`,``)):(l.removeAttribute(`data-instant`),p.removeAttribute(`data-instant`),t!==p&&t.removeAttribute(`data-instant`)),l.removeAttribute(`data-open`),p.removeAttribute(`data-open`),t!==p&&t.removeAttribute(`data-open`)},G=(0,e.createPresenceLifecycle)({element:p,onExitComplete:()=>{O||(L.restore(),p.hidden=!0)}}),K=(0,e.createPositionSync)({observedElements:[f,p],isActive:()=>E,ancestorScroll:!1,onUpdate:U}),q=(t,n,i=!1)=>{E!==t&&(!t&&E&&y>0&&(r=Date.now()+y),D=i,E=t,(0,e.setAria)(f,`expanded`,E),t?(L.mount(),p.hidden=!1,W(`open`),G.enter(),U(),K.start(),K.update()):(W(`closed`),G.exit(),K.stop()),H(E,n))},J=(e,t,n=!1)=>{if(E!==e){if(te){H(e,t);return}q(e,t,n)}},Y=(e,t,n=!1)=>{q(e,t,n)},X=(e,t)=>{e===f||!E||(V(),k=!1,A=!1,j=!1,J(!1,t,!0))};i.add(f),a.add(X),I.push(()=>{a.delete(X),i.delete(f)});let Z=e=>{if(B(),z(),y>0&&Date.now()<r){J(!0,e,!0);return}if(v<=0){J(!0,e);return}M=setTimeout(()=>{M=null,J(!0,e)},v)},de=e=>{if(z(),B(),b<=0){J(!1,e);return}N=setTimeout(()=>{N=null,J(!1,e)},b)},Q=e=>{k||A||j||de(e)};(0,e.setAria)(f,`expanded`,E),W(E?`open`:`closed`),p.hidden=!E,E&&(L.mount(),G.enter(),p.hidden=!1,U(),K.start(),K.update()),I.push((0,e.on)(l.ownerDocument,`keydown`,e=>{e.key===`Tab`&&(P=Date.now())},{capture:!0}),(0,e.on)(l.ownerDocument,`pointerdown`,()=>{P=-1/0,F=-1/0},{capture:!0}),(0,e.on)(l.ownerDocument,`pointermove`,e=>{e.pointerType!==`touch`&&(F=Date.now())},{capture:!0}),(0,e.on)(f,`pointerenter`,e=>{e.pointerType!==`touch`&&(k=!0,!R()&&(Date.now()-F>250||(s(f,`pointer`),Z(`pointer`))))}),(0,e.on)(f,`pointermove`,e=>{e.pointerType!==`touch`&&(!k||R()||E||M||(s(f,`pointer`),Z(`pointer`)))}),(0,e.on)(f,`pointerleave`,e=>{if(e.pointerType===`touch`)return;k=!1;let t=e.relatedTarget;if(!(t&&p.contains(t))){if(o(t,f)){J(!1,`pointer`,!0);return}Q(`pointer`)}})),I.push((0,e.on)(p,`pointerenter`,e=>{e.pointerType!==`touch`&&(A=!0,B())}),(0,e.on)(p,`pointerleave`,e=>{if(e.pointerType===`touch`)return;A=!1;let t=e.relatedTarget;if(!(t&&f.contains(t))){if(o(t,f)){J(!1,`pointer`,!0);return}Q(`pointer`)}})),I.push((0,e.on)(f,`focusin`,()=>{R()||Date.now()-P>750||(j=!0,s(f,`focus`),Z(`focus`))}),(0,e.on)(f,`focusout`,e=>{let t=e.relatedTarget;if(!(t&&(f.contains(t)||p.contains(t)))){if(j=!1,o(t,f)){J(!1,`blur`,!0);return}Q(`blur`)}}),(0,e.on)(p,`focusin`,()=>{j=!0,B()}),(0,e.on)(p,`focusout`,e=>{let t=e.relatedTarget;if(!(t&&(f.contains(t)||p.contains(t)))){if(j=!1,o(t,f)){J(!1,`blur`,!0);return}Q(`blur`)}})),I.push((0,e.createDismissLayer)({root:l,isOpen:()=>E,onDismiss:()=>J(!1,`dismiss`),closeOnClickOutside:re,closeOnEscape:ie})),I.push((0,e.on)(l,`hover-card:set`,e=>{let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&Y(n,`api`)}));let $={open:()=>{R()||(V(),J(!0,`api`))},close:()=>{V(),J(!1,`api`)},toggle:()=>{V(),!(!E&&R())&&J(!E,`api`)},setOpen:e=>{V(),Y(e,`api`)},get isOpen(){return E},destroy:()=>{O=!0,V(),K.stop(),G.cleanup(),L.cleanup(),I.forEach(e=>e()),I.length=0,(0,e.clearRootBinding)(l,c,$)}};return(0,e.setRootBinding)(l,c,$),$}function u(t=document){let n=[];for(let r of(0,e.getRoots)(t,`hover-card`))(0,e.hasRootBinding)(r,c)||n.push(l(r));return n}exports.create=u,exports.createHoverCard=l;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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 ee,ensureId as te,getDataBool as s,getDataEnum as c,getDataNumber as l,getPart as u,getRoots as d,hasRootBinding as f,measurePopupContentRect as ne,on as p,reuseRootBinding as re,setAria as m,setRootBinding as ie}from"@data-slot/core";const ae=[`top`,`right`,`bottom`,`left`],oe=[`start`,`center`,`end`];let se=0;const h=new Set,g=new Set,_=(e,t)=>{if(!e)return!1;for(let n of h)if(n!==t&&n.contains(e))return!0;return!1},v=(e,t)=>{for(let n of g)n(e,t)},y=`@data-slot/hover-card`;function b(d,f={}){let b=re(d,y,`[@data-slot/hover-card] createHoverCard() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(b)return b;let x=u(d,`hover-card-trigger`),S=u(d,`hover-card-content`),C=u(d,`hover-card-positioner`),w=C&&S&&C.contains(S)?C:null,T=u(d,`hover-card-portal`),ce=T&&w&&T.contains(w)?T:null;if(!x||!S)throw Error(`Hover-card requires trigger and content slots`);let le=f.open!==void 0,ue=f.defaultOpen??s(d,`defaultOpen`)??!1,de=f.delay??l(d,`delay`)??700,E=f.skipDelayDuration??l(d,`skipDelayDuration`)??300,fe=f.closeDelay??l(d,`closeDelay`)??300,pe=f.onOpenChange,me=f.closeOnClickOutside??s(d,`closeOnClickOutside`)??!0,he=f.closeOnEscape??s(d,`closeOnEscape`)??!0,ge=f.portal??s(S,`portal`)??s(d,`portal`)??!0,_e=(e,t)=>c(S,e,t)??(w?c(w,e,t):void 0)??c(d,e,t),D=e=>l(S,e)??(w?l(w,e):void 0)??l(d,e),ve=e=>s(S,e)??(w?s(w,e):void 0)??s(d,e),ye=f.side??_e(`side`,ae)??`bottom`,O=f.align??_e(`align`,oe)??`center`,be=f.sideOffset??D(`sideOffset`)??4,xe=f.alignOffset??D(`alignOffset`)??0,Se=f.avoidCollisions??ve(`avoidCollisions`)??!0,Ce=f.collisionPadding??D(`collisionPadding`)??8,k=f.open??ue,A=!1,j=!1,M=!1,N=!1,P=!1,F=null,I=null,L=-1/0,R=-1/0,z=[],B=i({content:S,root:d,enabled:ge,wrapperSlot:w?void 0:`hover-card-positioner`,container:w??void 0,mountTarget:w?ce??w:void 0}),we=te(S,`hover-card-content`);x.setAttribute(`aria-haspopup`,`dialog`),x.setAttribute(`aria-controls`,we),S.setAttribute(`data-side`,ye),S.setAttribute(`data-align`,O);let V=()=>x.hasAttribute(`disabled`)||x.getAttribute(`aria-disabled`)===`true`,H=()=>{F&&=(clearTimeout(F),null)},U=()=>{I&&=(clearTimeout(I),null)},W=()=>{H(),U()},Te=(e,t)=>{ee(d,`hover-card:change`,{open:e,reason:t,trigger:x,content:S}),pe?.(e)},G=()=>{let e=B.container,r=d.ownerDocument.defaultView??window,i=x.getBoundingClientRect(),a=t({anchorRect:i,contentRect:ne(S),side:ye,align:O,sideOffset:be,alignOffset:xe,avoidCollisions:Se,collisionPadding:Ce}),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`,S.setAttribute(`data-side`,a.side),S.setAttribute(`data-align`,a.align),e!==S&&(e.setAttribute(`data-side`,a.side),e.setAttribute(`data-align`,a.align))},K=e=>{let t=B.container;if(d.setAttribute(`data-state`,e),S.setAttribute(`data-state`,e),t!==S&&t.setAttribute(`data-state`,e),e===`open`){d.setAttribute(`data-open`,``),S.setAttribute(`data-open`,``),t!==S&&t.setAttribute(`data-open`,``),A?(d.setAttribute(`data-instant`,``),S.setAttribute(`data-instant`,``),t!==S&&t.setAttribute(`data-instant`,``)):(d.removeAttribute(`data-instant`),S.removeAttribute(`data-instant`),t!==S&&t.removeAttribute(`data-instant`)),d.removeAttribute(`data-closed`),S.removeAttribute(`data-closed`),t!==S&&t.removeAttribute(`data-closed`);return}d.setAttribute(`data-closed`,``),S.setAttribute(`data-closed`,``),t!==S&&t.setAttribute(`data-closed`,``),A?(d.setAttribute(`data-instant`,``),S.setAttribute(`data-instant`,``),t!==S&&t.setAttribute(`data-instant`,``)):(d.removeAttribute(`data-instant`),S.removeAttribute(`data-instant`),t!==S&&t.removeAttribute(`data-instant`)),d.removeAttribute(`data-open`),S.removeAttribute(`data-open`),t!==S&&t.removeAttribute(`data-open`)},q=o({element:S,onExitComplete:()=>{j||(B.restore(),S.hidden=!0)}}),J=a({observedElements:[x,S],isActive:()=>k,ancestorScroll:!1,onUpdate:G}),Ee=(e,t,n=!1)=>{k!==e&&(!e&&k&&E>0&&(se=Date.now()+E),A=n,k=e,m(x,`expanded`,k),e?(B.mount(),S.hidden=!1,K(`open`),q.enter(),G(),J.start(),J.update()):(K(`closed`),q.exit(),J.stop()),Te(k,t))},Y=(e,t,n=!1)=>{if(k!==e){if(le){Te(e,t);return}Ee(e,t,n)}},X=(e,t,n=!1)=>{Ee(e,t,n)},De=(e,t)=>{e===x||!k||(W(),M=!1,N=!1,P=!1,Y(!1,t,!0))};h.add(x),g.add(De),z.push(()=>{g.delete(De),h.delete(x)});let Z=e=>{if(U(),H(),E>0&&Date.now()<se){Y(!0,e,!0);return}if(de<=0){Y(!0,e);return}F=setTimeout(()=>{F=null,Y(!0,e)},de)},Oe=e=>{if(H(),U(),fe<=0){Y(!1,e);return}I=setTimeout(()=>{I=null,Y(!1,e)},fe)},Q=e=>{M||N||P||Oe(e)};m(x,`expanded`,k),K(k?`open`:`closed`),S.hidden=!k,k&&(B.mount(),q.enter(),S.hidden=!1,G(),J.start(),J.update()),z.push(p(d.ownerDocument,`keydown`,e=>{e.key===`Tab`&&(L=Date.now())},{capture:!0}),p(d.ownerDocument,`pointerdown`,()=>{L=-1/0,R=-1/0},{capture:!0}),p(d.ownerDocument,`pointermove`,e=>{e.pointerType!==`touch`&&(R=Date.now())},{capture:!0}),p(x,`pointerenter`,e=>{e.pointerType!==`touch`&&(M=!0,!V()&&(Date.now()-R>250||(v(x,`pointer`),Z(`pointer`))))}),p(x,`pointermove`,e=>{e.pointerType!==`touch`&&(!M||V()||k||F||(v(x,`pointer`),Z(`pointer`)))}),p(x,`pointerleave`,e=>{if(e.pointerType===`touch`)return;M=!1;let t=e.relatedTarget;if(!(t&&S.contains(t))){if(_(t,x)){Y(!1,`pointer`,!0);return}Q(`pointer`)}})),z.push(p(S,`pointerenter`,e=>{e.pointerType!==`touch`&&(N=!0,U())}),p(S,`pointerleave`,e=>{if(e.pointerType===`touch`)return;N=!1;let t=e.relatedTarget;if(!(t&&x.contains(t))){if(_(t,x)){Y(!1,`pointer`,!0);return}Q(`pointer`)}})),z.push(p(x,`focusin`,()=>{V()||Date.now()-L>750||(P=!0,v(x,`focus`),Z(`focus`))}),p(x,`focusout`,e=>{let t=e.relatedTarget;if(!(t&&(x.contains(t)||S.contains(t)))){if(P=!1,_(t,x)){Y(!1,`blur`,!0);return}Q(`blur`)}}),p(S,`focusin`,()=>{P=!0,U()}),p(S,`focusout`,e=>{let t=e.relatedTarget;if(!(t&&(x.contains(t)||S.contains(t)))){if(P=!1,_(t,x)){Y(!1,`blur`,!0);return}Q(`blur`)}})),z.push(r({root:d,isOpen:()=>k,onDismiss:()=>Y(!1,`dismiss`),closeOnClickOutside:me,closeOnEscape:he})),z.push(p(d,`hover-card:set`,e=>{let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&X(n,`api`)}));let $={open:()=>{V()||(W(),Y(!0,`api`))},close:()=>{W(),Y(!1,`api`)},toggle:()=>{W(),!(!k&&V())&&Y(!k,`api`)},setOpen:e=>{W(),X(e,`api`)},get isOpen(){return k},destroy:()=>{j=!0,W(),J.stop(),q.cleanup(),B.cleanup(),z.forEach(e=>e()),z.length=0,e(d,y,$)}};return ie(d,y,$),$}function x(e=document){let t=[];for(let n of d(e,`hover-card`))f(n,y)||t.push(b(n));return t}export{x as create,b as createHoverCard};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-slot/hover-card",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.124",
|
|
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.124"
|
|
39
39
|
}
|
|
40
40
|
}
|