@zag-js/tooltip 0.0.0-dev-20220412212252 → 0.0.0-dev-20220413175519
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2610 -1
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +2591 -1
- package/dist/index.mjs.map +3 -3
- package/dist/tooltip.connect.d.ts +1 -0
- package/dist/tooltip.connect.d.ts.map +1 -0
- package/dist/tooltip.dom.d.ts +1 -0
- package/dist/tooltip.dom.d.ts.map +1 -0
- package/dist/tooltip.machine.d.ts +1 -0
- package/dist/tooltip.machine.d.ts.map +1 -0
- package/dist/tooltip.store.d.ts +1 -0
- package/dist/tooltip.store.d.ts.map +1 -0
- package/dist/tooltip.types.d.ts +1 -0
- package/dist/tooltip.types.d.ts.map +1 -0
- package/package.json +16 -7
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2611 @@
|
|
|
1
|
-
var St=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Ye=(t,e)=>{for(var n in e)St(t,n,{get:e[n],enumerable:!0})},Ue=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $e(e))!qe.call(t,i)&&i!==n&&St(t,i,{get:()=>e[i],enumerable:!(r=Ke(e,i))||r.enumerable});return t};var Xe=t=>Ue(St({},"__esModule",{value:!0}),t);var Tr={};Ye(Tr,{connect:()=>_e,machine:()=>ze});module.exports=Xe(Tr);var $t=t=>t?"":void 0;var Kt=new WeakMap;function Ge(t){var e;if(!t)return{};let n=Kt.get(t);return n||(n=((e=t?.ownerDocument.defaultView)!=null?e:window).getComputedStyle(t),Kt.set(t,n)),n}function qt(t){let e=globalThis.requestAnimationFrame(t);return function(){globalThis.cancelAnimationFrame(e)}}var Je=()=>{};var Ar=(()=>{let t=0;return()=>(t++,t.toString(36))})();var V=new Map,M=new Map;function Ze(t,e,n,r){var i;if(!t)return Je;let l=JSON.stringify({type:e,options:r}),d=V.get(t);if(V.has(t))d!=null&&d.has(l)?(i=d?.get(l))==null||i.add(n):d?.set(l,new Set([n]));else{let s=new Map([[l,new Set([n])]]);V.set(t,s)}function f(s){var y,w;function g(u){var p;let o=V.get(s);(p=o?.get(l))==null||p.forEach(a=>a(u))}if(!(M!=null&&M.has(s))){M.set(s,new Map([[l,g]])),s.addEventListener(e,g,r);return}(y=M?.get(s))!=null&&y.has(l)||((w=M.get(s))==null||w.set(l,g),s.addEventListener(e,g,r))}return f(t),function(){var s,y,w,g;if(!V.has(t))return;let u=V.get(t);if((s=u?.get(l))==null||s.delete(n),((y=u?.get(l))==null?void 0:y.size)===0){let p=(w=M.get(t))==null?void 0:w.get(l);t.removeEventListener(e,p,r),u?.delete(l),(g=M.get(t))==null||g.delete(l),u?.size===0&&(V.delete(t),M.delete(t))}}}var Pt=t=>Object.prototype.toString.call(t).slice(8,-1),Qe=t=>Pt(t)==="Object"&&"current"in t,tn=t=>Pt(t)==="Function"?t():t,en=t=>Pt(t)==="Object"&&!!t.touches,nn={pageX:0,pageY:0,clientX:0,clientY:0};function rn(t,e="page"){let n=en(t)?t.touches[0]||t.changedTouches[0]||nn:t;return{point:{x:n[`${e}X`],y:n[`${e}Y`]}}}function at(t,e,n,r){let i=Qe(t)?t.current:tn(t);return Ze(i,e,n,r)}function Yt(t,e,n,r){var i;let l=(i=fn(e))!=null?i:e;return at(t,l,on(n,e==="pointerdown"),r)}function on(t,e=!1){let n=r=>{t(r,rn(r))};return e?ln(n):n}function ln(t){return e=>{var n;let r=(n=e.view)!=null?n:window,i=e instanceof r.MouseEvent;(!i||i&&e.button===0)&&t(e)}}var an=()=>typeof window<"u"&&window.onpointerdown===null,sn=()=>typeof window<"u"&&window.ontouchstart===null,cn=()=>typeof window<"u"&&window.onmousedown===null,un={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},dn={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function fn(t){return an()?t:sn()?dn[t]:cn()?un[t]:t}function Lt(t){var e;return Gt(t)?t.document:(e=t?.ownerDocument)!=null?e:document}function hn(t){var e;return(e=t?.ownerDocument.defaultView)!=null?e:window}function Ut(t){return Gt(t)?"":t&&t.localName||""}function Xt(t){let e=Lt(t);return Ut(t)==="html"?t:t.assignedSlot||t.parentElement||e.documentElement}function Tt(t){return typeof t=="object"&&t?.nodeType===Node.ELEMENT_NODE&&typeof t?.nodeName=="string"}function Gt(t){return t?.toString()==="[object Window]"}function Jt(t){let{overflow:e,overflowX:n,overflowY:r}=Ge(t);return/auto|scroll|overlay|hidden/.test(e+r+n)}function st(t){return["html","body","#document"].includes(Ut(t))?Lt(t).body:Tt(t)&&Jt(t)?t:st(Xt(t))}function Ot(t,e=[]){let n=st(t),r=n===Lt(t).body,i=hn(n),l=r?[i].concat(i.visualViewport||[],Jt(n)?n:[]):n,d=e.concat(l);return r?d:d.concat(Ot(Xt(l)))}var Cr=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");var Zt={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};function Qt(t,e){return t.addEventListener("webkitpointerlockchange",e,!1),t.addEventListener("mozpointerlockchange",e,!1),t.addEventListener("pointerlockchange",e,!1),function(){t.removeEventListener("mozpointerlockchange",e,!1),t.removeEventListener("pointerlockchange",e,!1)}}function U(t){return t.split("-")[0]}function ht(t){return t.split("-")[1]}function J(t){return["top","bottom"].includes(U(t))?"x":"y"}function Rt(t){return t==="y"?"height":"width"}function te(t,e,n){let{reference:r,floating:i}=t,l=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=J(e),s=Rt(f),y=r[s]/2-i[s]/2,w=U(e),g=f==="x",u;switch(w){case"top":u={x:l,y:r.y-i.height};break;case"bottom":u={x:l,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:d};break;case"left":u={x:r.x-i.width,y:d};break;default:u={x:r.x,y:r.y}}switch(ht(e)){case"start":u[f]-=y*(n&&g?-1:1);break;case"end":u[f]+=y*(n&&g?-1:1);break}return u}var pn=async(t,e,n)=>{let{placement:r="bottom",strategy:i="absolute",middleware:l=[],platform:d}=n,f=await(d.isRTL==null?void 0:d.isRTL(e)),s=await d.getElementRects({reference:t,floating:e,strategy:i}),{x:y,y:w}=te(s,r,f),g=r,u={},p=0;for(let o=0;o<l.length;o++){let{name:a,fn:c}=l[o],{x:h,y:m,data:v,reset:b}=await c({x:y,y:w,initialPlacement:r,placement:g,strategy:i,middlewareData:u,rects:s,platform:d,elements:{reference:t,floating:e}});if(y=h??y,w=m??w,u={...u,[a]:{...u[a],...v}},b){typeof b=="object"&&(b.placement&&(g=b.placement),b.rects&&(s=b.rects===!0?await d.getElementRects({reference:t,floating:e,strategy:i}):b.rects),{x:y,y:w}=te(s,g,f)),o=-1;continue}}return{x:y,y:w,placement:g,strategy:i,middlewareData:u}};function gn(t){return{top:0,right:0,bottom:0,left:0,...t}}function de(t){return typeof t!="number"?gn(t):{top:t,right:t,bottom:t,left:t}}function ut(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function It(t,e){var n;e===void 0&&(e={});let{x:r,y:i,platform:l,rects:d,elements:f,strategy:s}=t,{boundary:y="clippingAncestors",rootBoundary:w="viewport",elementContext:g="floating",altBoundary:u=!1,padding:p=0}=e,o=de(p),a=f[u?g==="floating"?"reference":"floating":g],c=ut(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(a)))==null||n?a:a.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(f.floating)),boundary:y,rootBoundary:w,strategy:s})),h=ut(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({rect:g==="floating"?{...d.floating,x:r,y:i}:d.reference,offsetParent:await(l.getOffsetParent==null?void 0:l.getOffsetParent(f.floating)),strategy:s}):d[g]);return{top:c.top-h.top+o.top,bottom:h.bottom-c.bottom+o.bottom,left:c.left-h.left+o.left,right:h.right-c.right+o.right}}var mn=Math.min,F=Math.max;function At(t,e,n){return F(t,mn(e,n))}var vn=t=>({name:"arrow",options:t,async fn(e){let{element:n,padding:r=0}=t??{},{x:i,y:l,placement:d,rects:f,platform:s}=e;if(n==null)return{};let y=de(r),w={x:i,y:l},g=J(d),u=Rt(g),p=await s.getDimensions(n),o=g==="y"?"top":"left",a=g==="y"?"bottom":"right",c=f.reference[u]+f.reference[g]-w[g]-f.floating[u],h=w[g]-f.reference[g],m=await(s.getOffsetParent==null?void 0:s.getOffsetParent(n)),v=m?g==="y"?m.clientHeight||0:m.clientWidth||0:0,b=c/2-h/2,x=y[o],A=v-p[u]-y[a],T=v/2-p[u]/2+b,O=At(x,T,A);return{data:{[g]:O,centerOffset:T-O}}}}),yn={left:"right",right:"left",bottom:"top",top:"bottom"};function dt(t){return t.replace(/left|right|bottom|top/g,e=>yn[e])}function wn(t,e,n){n===void 0&&(n=!1);let r=ht(t),i=J(t),l=Rt(i),d=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(d=dt(d)),{main:d,cross:dt(d)}}var bn={start:"end",end:"start"};function ee(t){return t.replace(/start|end/g,e=>bn[e])}function En(t){let e=dt(t);return[ee(t),e,ee(e)]}var xn=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n;let{placement:r,middlewareData:i,rects:l,initialPlacement:d,platform:f,elements:s}=e,{mainAxis:y=!0,crossAxis:w=!0,fallbackPlacements:g,fallbackStrategy:u="bestFit",flipAlignment:p=!0,...o}=t,a=U(r),c=g||(a===d||!p?[dt(d)]:En(d)),h=[d,...c],m=await It(e,o),v=[],b=((n=i.flip)==null?void 0:n.overflows)||[];if(y&&v.push(m[a]),w){let{main:O,cross:ot}=wn(r,l,await(f.isRTL==null?void 0:f.isRTL(s.floating)));v.push(m[O],m[ot])}if(b=[...b,{placement:r,overflows:v}],!v.every(O=>O<=0)){var x,A;let O=((x=(A=i.flip)==null?void 0:A.index)!=null?x:0)+1,ot=h[O];if(ot)return{data:{index:O,overflows:b},reset:{placement:ot}};let lt="bottom";switch(u){case"bestFit":{var T;let Ft=(T=b.slice().sort((Be,Fe)=>Be.overflows.filter(H=>H>0).reduce((H,xt)=>H+xt,0)-Fe.overflows.filter(H=>H>0).reduce((H,xt)=>H+xt,0))[0])==null?void 0:T.placement;Ft&&(lt=Ft);break}case"initialPlacement":lt=d;break}if(r!==lt)return{reset:{placement:lt}}}return{}}}};function Sn(t,e,n,r){r===void 0&&(r=!1);let i=U(t),l=ht(t),d=J(t)==="x",f=["left","top"].includes(i)?-1:1,s=r&&d?-1:1,y=typeof n=="function"?n({...e,placement:t}):n,w=typeof y=="number",{mainAxis:g,crossAxis:u,alignmentAxis:p}=w?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...y};return l&&typeof p=="number"&&(u=l==="end"?p*-1:p),d?{x:u*s,y:g*f}:{x:g*f,y:u*s}}var Pn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:n,y:r,placement:i,rects:l,platform:d,elements:f}=e,s=Sn(i,l,t,await(d.isRTL==null?void 0:d.isRTL(f.floating)));return{x:n+s.x,y:r+s.y,data:s}}}};function Ln(t){return t==="x"?"y":"x"}var Tn=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:i}=e,{mainAxis:l=!0,crossAxis:d=!1,limiter:f={fn:c=>{let{x:h,y:m}=c;return{x:h,y:m}}},...s}=t,y={x:n,y:r},w=await It(e,s),g=J(U(i)),u=Ln(g),p=y[g],o=y[u];if(l){let c=g==="y"?"top":"left",h=g==="y"?"bottom":"right",m=p+w[c],v=p-w[h];p=At(m,p,v)}if(d){let c=u==="y"?"top":"left",h=u==="y"?"bottom":"right",m=o+w[c],v=o-w[h];o=At(m,o,v)}let a=f.fn({...e,[g]:p,[u]:o});return{...a,data:{x:a.x-n,y:a.y-r}}}}},On=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){let{placement:n,rects:r,platform:i,elements:l}=e,{apply:d,...f}=t,s=await It(e,f),y=U(n),w=ht(n),g,u;y==="top"||y==="bottom"?(g=y,u=w===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(u=y,g=w==="end"?"top":"bottom");let p=F(s.left,0),o=F(s.right,0),a=F(s.top,0),c=F(s.bottom,0),h={height:r.floating.height-(["left","right"].includes(n)?2*(a!==0||c!==0?a+c:F(s.top,s.bottom)):s[g]),width:r.floating.width-(["top","bottom"].includes(n)?2*(p!==0||o!==0?p+o:F(s.left,s.right)):s[u])},m=await i.getDimensions(l.floating);d?.({...h,...r});let v=await i.getDimensions(l.floating);return m.width!==v.width||m.height!==v.height?{reset:{rects:!0}}:{}}}};function fe(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function N(t){if(t==null)return window;if(!fe(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function Z(t){return N(t).getComputedStyle(t)}function D(t){return fe(t)?"":t?(t.nodeName||"").toLowerCase():""}function C(t){return t instanceof N(t).HTMLElement}function Y(t){return t instanceof N(t).Element}function An(t){return t instanceof N(t).Node}function Mt(t){let e=N(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function pt(t){let{overflow:e,overflowX:n,overflowY:r}=Z(t);return/auto|scroll|overlay|hidden/.test(e+r+n)}function Cn(t){return["table","td","th"].includes(D(t))}function he(t){let e=navigator.userAgent.toLowerCase().includes("firefox"),n=Z(t);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||e&&n.willChange==="filter"||e&&(n.filter?n.filter!=="none":!1)}function pe(){return!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var ne=Math.min,G=Math.max,ft=Math.round;function $(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);let r=t.getBoundingClientRect(),i=1,l=1;e&&C(t)&&(i=t.offsetWidth>0&&ft(r.width)/t.offsetWidth||1,l=t.offsetHeight>0&&ft(r.height)/t.offsetHeight||1);let d=Y(t)?N(t):window,f=!pe()&&n,s=(r.left+(f?d.visualViewport.offsetLeft:0))/i,y=(r.top+(f?d.visualViewport.offsetTop:0))/l,w=r.width/i,g=r.height/l;return{width:w,height:g,top:y,right:s+w,bottom:y+g,left:s,x:s,y}}function j(t){return((An(t)?t.ownerDocument:t.document)||window.document).documentElement}function gt(t){return Y(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ge(t){return $(j(t)).left+gt(t).scrollLeft}function kn(t){let e=$(t);return ft(e.width)!==t.offsetWidth||ft(e.height)!==t.offsetHeight}function Rn(t,e,n){let r=C(e),i=j(e),l=$(t,r&&kn(e),n==="fixed"),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};if(r||!r&&n!=="fixed")if((D(e)!=="body"||pt(i))&&(d=gt(e)),C(e)){let s=$(e,!0);f.x=s.x+e.clientLeft,f.y=s.y+e.clientTop}else i&&(f.x=ge(i));return{x:l.left+d.scrollLeft-f.x,y:l.top+d.scrollTop-f.y,width:l.width,height:l.height}}function Dt(t){return D(t)==="html"?t:t.assignedSlot||t.parentNode||(Mt(t)?t.host:null)||j(t)}function re(t){return!C(t)||getComputedStyle(t).position==="fixed"?null:t.offsetParent}function In(t){let e=Dt(t);for(Mt(e)&&(e=e.host);C(e)&&!["html","body"].includes(D(e));){if(he(e))return e;e=e.parentNode}return null}function Ct(t){let e=N(t),n=re(t);for(;n&&Cn(n)&&getComputedStyle(n).position==="static";)n=re(n);return n&&(D(n)==="html"||D(n)==="body"&&getComputedStyle(n).position==="static"&&!he(n))?e:n||In(t)||e}function ie(t){if(C(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=$(t);return{width:e.width,height:e.height}}function Mn(t){let{rect:e,offsetParent:n,strategy:r}=t,i=C(n),l=j(n);if(n===l)return e;let d={scrollLeft:0,scrollTop:0},f={x:0,y:0};if((i||!i&&r!=="fixed")&&((D(n)!=="body"||pt(l))&&(d=gt(n)),C(n))){let s=$(n,!0);f.x=s.x+n.clientLeft,f.y=s.y+n.clientTop}return{...e,x:e.x-d.scrollLeft+f.x,y:e.y-d.scrollTop+f.y}}function Dn(t,e){let n=N(t),r=j(t),i=n.visualViewport,l=r.clientWidth,d=r.clientHeight,f=0,s=0;if(i){l=i.width,d=i.height;let y=pe();(y||!y&&e==="fixed")&&(f=i.offsetLeft,s=i.offsetTop)}return{width:l,height:d,x:f,y:s}}function Nn(t){var e;let n=j(t),r=gt(t),i=(e=t.ownerDocument)==null?void 0:e.body,l=G(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),d=G(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),f=-r.scrollLeft+ge(t),s=-r.scrollTop;return Z(i||n).direction==="rtl"&&(f+=G(n.clientWidth,i?i.clientWidth:0)-l),{width:l,height:d,x:f,y:s}}function me(t){let e=Dt(t);return["html","body","#document"].includes(D(e))?t.ownerDocument.body:C(e)&&pt(e)?e:me(e)}function Nt(t,e){var n;e===void 0&&(e=[]);let r=me(t),i=r===((n=t.ownerDocument)==null?void 0:n.body),l=N(r),d=i?[l].concat(l.visualViewport||[],pt(r)?r:[]):r,f=e.concat(d);return i?f:f.concat(Nt(Dt(d)))}function Wn(t,e){let n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Mt(n)){let r=e;do{if(r&&t===r)return!0;r=r.parentNode||r.host}while(r)}return!1}function jn(t,e){let n=$(t,!1,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft;return{top:r,left:i,x:i,y:r,right:i+t.clientWidth,bottom:r+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}function oe(t,e,n){return e==="viewport"?ut(Dn(t,n)):Y(e)?jn(e,n):ut(Nn(j(t)))}function _n(t){let e=Nt(t),n=["absolute","fixed"].includes(Z(t).position)&&C(t)?Ct(t):t;return Y(n)?e.filter(r=>Y(r)&&Wn(r,n)&&D(r)!=="body"):[]}function Hn(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t,l=[...n==="clippingAncestors"?_n(e):[].concat(n),r],d=l[0],f=l.reduce((s,y)=>{let w=oe(e,y,i);return s.top=G(w.top,s.top),s.right=ne(w.right,s.right),s.bottom=ne(w.bottom,s.bottom),s.left=G(w.left,s.left),s},oe(e,d,i));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}}var Vn={getClippingRect:Hn,convertOffsetParentRelativeRectToViewportRelativeRect:Mn,isElement:Y,getDimensions:ie,getOffsetParent:Ct,getDocumentElement:j,getElementRects:t=>{let{reference:e,floating:n,strategy:r}=t;return{reference:Rn(e,Ct(n),r),floating:{...ie(n),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>Z(t).direction==="rtl"},zn=(t,e,n)=>pn(t,e,{platform:Vn,...n}),Bn=()=>{},Rr=(()=>{let t=0;return()=>(t++,t.toString(36))})(),z=new Map,W=new Map;function Fn(t,e,n,r){var i;if(!t)return Bn;let l=JSON.stringify({type:e,options:r}),d=z.get(t);if(z.has(t))d!=null&&d.has(l)?(i=d?.get(l))==null||i.add(n):d?.set(l,new Set([n]));else{let s=new Map([[l,new Set([n])]]);z.set(t,s)}function f(s){var y,w;function g(u){var p;(p=z.get(s)?.get(l))==null||p.forEach(a=>a(u))}if(!(W!=null&&W.has(s))){W.set(s,new Map([[l,g]])),s.addEventListener(e,g,r);return}(y=W?.get(s))!=null&&y.has(l)||((w=W.get(s))==null||w.set(l,g),s.addEventListener(e,g,r))}return f(t),function(){var s,y,w,g;if(!z.has(t))return;let u=z.get(t);if((s=u?.get(l))==null||s.delete(n),((y=u?.get(l))==null?void 0:y.size)===0){let p=(w=W.get(t))==null?void 0:w.get(l);t.removeEventListener(e,p,r),u?.delete(l),(g=W.get(t))==null||g.delete(l),u?.size===0&&(z.delete(t),W.delete(t))}}}var ve=t=>Object.prototype.toString.call(t).slice(8,-1),Kn=t=>ve(t)==="Object"&&"current"in t,$n=t=>ve(t)==="Function"?t():t;function le(t,e,n,r){let i=Kn(t)?t.current:$n(t);return Fn(i,e,n,r)}function qn(t){var e;return Yn(t)?t.document:(e=t?.ownerDocument)!=null?e:document}function ae(t){return typeof t=="object"&&t?.nodeType===Node.ELEMENT_NODE&&typeof t?.nodeName=="string"}function Yn(t){return t?.toString()==="[object Window]"}var Ir=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(","),K=new Map;function se(t,e){let n=K.get(t);return n?(n.callbacks.push(e),e(t.getBoundingClientRect())):(K.set(t,{rect:{},callbacks:[e]}),K.size===1&&(kt=requestAnimationFrame(ye))),function(){let r=K.get(t);if(!r)return;let i=r.callbacks.indexOf(e);i>-1&&r.callbacks.splice(i,1),r.callbacks.length===0&&(K.delete(t),K.size===0&&cancelAnimationFrame(kt))}}var kt;function ye(){let t=[];K.forEach((e,n)=>{let r=n.getBoundingClientRect();Un(e.rect,r)||(e.rect=r,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(n=>n(e.rect))}),kt=requestAnimationFrame(ye)}function Un(t,e){return t.width===e.width&&t.height===e.height&&t.top===e.top&&t.right===e.right&&t.bottom===e.bottom&&t.left===e.left}var ce=()=>{},ct=(...t)=>e=>t.reduce((n,r)=>r(n),e),Mr=(()=>{let t=0;return()=>(t++,t.toString(36))})(),Xn=t=>t===!0||t===!1;function Gn(t){return Xn(t)?{ancestorResize:t,ancestorScroll:t,referenceResize:t}:Object.assign({ancestorResize:!0,ancestorScroll:!0,referenceResize:!0},t)}function Jn(t,e,n,r=!1){let{ancestorScroll:i,ancestorResize:l,referenceResize:d}=Gn(r),f=i||l,s=[];f&&ae(t)&&s.push(...Nt(t));function y(){let g=[se(e,n)];return d&&ae(t)&&g.push(se(t,n)),g.push(ct(...s.map(u=>le(u,"resize",n)))),()=>g.forEach(u=>u())}function w(){return ct(...s.map(g=>le(g,"scroll",n,{passive:!0})))}return ct(y(),w())}var B=t=>({variable:t,reference:`var(${t})`}),S={arrowShadowColor:B("--arrow-shadow-color"),arrowSize:B("--arrow-size"),arrowSizeHalf:B("--arrow-size-half"),arrowBg:B("--arrow-background"),transformOrigin:B("--transform-origin"),arrowOffset:B("--arrow-offset"),boxShadow:B("--arrow-box-shadow")},ue={top:"bottom center","top-start":"bottom left","top-end":"bottom right",bottom:"top center","bottom-start":"top left","bottom-end":"top right",left:"right center","left-start":"right top","left-end":"right bottom",right:"left center","right-start":"left top","right-end":"left bottom"},Zn={name:"transformOrigin",fn({placement:t,elements:e}){let{floating:n}=e;return n.style.setProperty(S.transformOrigin.variable,ue[t]),{data:{transformOrigin:ue[t]}}}},Qn=t=>({name:"shiftArrow",fn({placement:e,middlewareData:n}){var r;let{element:i}=t,{x:l,y:d}=(r=n.arrow)!=null?r:{x:0,y:0},f={top:"bottom",right:"left",bottom:"top",left:"right"}[e.split("-")[0]];return Object.assign(i.style,{top:`${d}px`,left:`${l}px`,[f]:S.arrowOffset.reference,[S.boxShadow.variable]:tr(e)}),{}}});function tr(t){if(t.includes("top"))return`1px 1px 1px 0 ${S.arrowShadowColor.reference}`;if(t.includes("bottom"))return`-1px -1px 1px 0 ${S.arrowShadowColor.reference}`;if(t.includes("right"))return`-1px 1px 1px 0 ${S.arrowShadowColor.reference}`;if(t.includes("left"))return`1px -1px 1px 0 ${S.arrowShadowColor.reference}`}var er={strategy:"absolute",placement:"bottom",listeners:!0,gutter:8,flip:!0,sameWidth:!1};function we(t,e,n={}){var r;if(t==null||e==null)return ce;n=Object.assign({},er,n);let i=[Zn];if(n.flip&&i.push(xn({boundary:n.boundary,padding:8})),n.gutter||n.offset){let f=n.gutter?{mainAxis:n.gutter}:n.offset;i.push(Pn(f))}i.push(Tn({boundary:n.boundary}));let l=qn(e).querySelector("[data-part=arrow]");l&&i.push(vn({element:l,padding:8}),Qn({element:l})),n.sameWidth&&i.push(On({apply(f){let{width:s}=f.reference;Object.assign(e.style,{width:`${s}px`,minWidth:"unset"})}}));function d(){if(t==null||e==null)return;let{placement:f,strategy:s}=n;zn(t,e,{placement:f,middleware:i,strategy:s}).then(y=>{let{x:w,y:g,strategy:u}=y;return Object.assign(e.style,{left:`${w}px`,top:`${g}px`,position:u}),y}).then(y=>{var w;(w=n.onComplete)==null||w.call(n,y)})}return d(),ct(Jn(t,e,d,n.listeners),(r=n.onCleanup)!=null?r:ce)}var nr={position:"fixed",top:0,left:0,opacity:0,transform:"translate3d(0, -200%, 0)",pointerEvents:"none"};function be(t){let{measured:e,strategy:n="absolute"}=t;return{arrow:{position:"absolute",width:S.arrowSize.reference,height:S.arrowSize.reference,[S.arrowSizeHalf.variable]:`calc(${S.arrowSize.reference} / 2)`,[S.arrowOffset.variable]:`calc(${S.arrowSizeHalf.reference} * -1)`,opacity:e?void 0:0},innerArrow:{transform:"rotate(45deg)",background:S.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:n,minWidth:"max-content",...!e&&nr}}}function rr(t){return{button:t,label:t,input:t,output:t,element:t}}var Ee=rr(t=>t);var E={getDoc:t=>t.doc||document,getWin:t=>{var e;return((e=t.doc)==null?void 0:e.defaultView)||window},getTriggerId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.trigger)!=null?n:`tooltip-${t.id}--trigger`},getContentId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.content)!=null?n:`tooltip-${t.id}--content`},getArrowId:t=>`tooltip-${t.id}--arrow`,getPositionerId:t=>`tooltip-${t.id}--popper`,portalId:"tooltip-portal",getTriggerEl:t=>E.getDoc(t).getElementById(E.getTriggerId(t)),getContentEl:t=>E.getDoc(t).getElementById(E.getContentId(t)),getPositionerEl:t=>E.getDoc(t).getElementById(E.getPositionerId(t)),getArrowEl:t=>E.getDoc(t).getElementById(E.getArrowId(t)),getScrollParent:t=>st(E.getTriggerEl(t)),getPortalEl:t=>E.getDoc(t).getElementById(E.portalId),createPortalEl:t=>{let e=E.getDoc(t).createElement("tooltip-portal");return e.id=E.portalId,e}};var Et={},_r=Symbol(),Hr=Symbol(),ir=Symbol(),xe=Object.getPrototypeOf,Ht=new WeakMap,or=t=>t&&(Ht.has(t)?Ht.get(t):xe(t)===Object.prototype||xe(t)===Array.prototype),lr=t=>or(t)&&t[ir]||null,Se=(t,e=!0)=>{Ht.set(t,e)},Ie=Symbol(),k=Symbol(),yt=Symbol(),ar=Symbol(),Q=Symbol(),Pe=Symbol(),Bt=new WeakSet;function wt(t){return Bt.add(t),t}var bt=t=>typeof t=="object"&&t!==null,sr=t=>bt(t)&&!Bt.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),Le=new WeakMap,Te=1,Oe=new WeakMap;function rt(t={}){if(!bt(t))throw new Error("object required");let e=Le.get(t);if(e)return e;let n=Te,r=new Set,i=(u,p=++Te)=>{n!==p&&(n=p,r.forEach(o=>o(u,p)))},l=new Map,d=u=>{let p=l.get(u);return p||(p=(o,a)=>{let c=[...o];c[1]=[u,...c[1]],i(c,a)},l.set(u,p)),p},f=u=>{let p=l.get(u);return l.delete(u),p},s=(u,p)=>{let o=Oe.get(p);if(o?.[0]===n)return o[1];let a=Array.isArray(u)?[]:Object.create(Object.getPrototypeOf(u));return Se(a,!0),Oe.set(p,[n,a]),Reflect.ownKeys(u).forEach(c=>{let h=Reflect.get(u,c,p);if(Bt.has(h))Se(h,!1),a[c]=h;else if(h instanceof Promise)if(Q in h)a[c]=h[Q];else{let m=h[Pe]||h;Object.defineProperty(a,c,{get(){if(Q in h)return h[Q];throw m}})}else h?.[k]?a[c]=h[yt]:a[c]=h}),Object.freeze(a),a},y=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),w={get(u,p,o){return p===Ie?n:p===k?r:p===yt?s(u,o):p===ar?w:Reflect.get(u,p,o)},deleteProperty(u,p){let o=Reflect.get(u,p),a=o?.[k];a&&a.delete(f(p));let c=Reflect.deleteProperty(u,p);return c&&i(["delete",[p],o]),c},is:Object.is,canProxy:sr,set(u,p,o,a){var c;let h=Reflect.get(u,p,a);if(this.is(h,o))return!0;let m=h?.[k];m&&m.delete(f(p)),bt(o)&&(o=lr(o)||o);let v;return(c=Object.getOwnPropertyDescriptor(u,p))!=null&&c.set?v=o:o instanceof Promise?v=o.then(b=>(v[Q]=b,i(["resolve",[p],b]),b)).catch(b=>{v[Pe]=b,i(["reject",[p],b])}):o?.[k]?(v=o,v[k].add(d(p))):this.canProxy(o)?(v=rt(o),v[k].add(d(p))):v=o,Reflect.set(u,p,v,a),i(["set",[p],o,h]),!0}},g=new Proxy(y,w);return Le.set(t,g),Reflect.ownKeys(t).forEach(u=>{let p=Object.getOwnPropertyDescriptor(t,u);p.get||p.set?Object.defineProperty(y,u,p):g[u]=t[u]}),g}function Ae(t){return bt(t)?t[Ie]:void 0}function it(t,e,n){(Et.env&&Et.env.MODE)!=="production"&&!t?.[k]&&console.warn("Please use proxy object");let r,i=[],l=d=>{if(i.push(d),n){e(i.splice(0));return}r||(r=Promise.resolve().then(()=>{r=void 0,e(i.splice(0))}))};return t[k].add(l),()=>{t[k].delete(l)}}function cr(t){return(Et.env&&Et.env.MODE)!=="production"&&!t?.[yt]&&console.warn("Please use proxy object"),t[yt]}function ur(t){for(;t.length>0;)t.pop();return t}var Ce=(t,...e)=>(typeof t=="function"?t(...e):t)??void 0,R=t=>t,ke=()=>{};var dr=(()=>{let t=0;return()=>(t++,t.toString(36))})(),X=t=>Array.isArray(t),et=t=>!(t==null||typeof t!="object"||X(t)),fr=t=>typeof t=="number"&&!Number.isNaN(t),I=t=>typeof t=="string",Vt=t=>typeof t=="function";function Wt(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function jt(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function hr(t){return et(t)&&t.predicate!=null}function _t(t,e){return(n,r)=>hr(t)?t.predicate(e??{})(n,r):t}function pr(t){return et(t)&&t.predicate!=null}var gr=()=>!0;function Me(t,e){return t=t??gr,(n,r)=>{if(I(t)){let i=e?.[t];return Vt(i)?i(n,r):i}return pr(t)?t.predicate(e??{})(n,r):t?.(n,r)}}function tt(t){var e,n,r;if(Array.isArray(t)){for(n=Array(e=t.length);e--;)n[e]=(r=t[e])&&typeof r=="object"?tt(r):r;return n}if(Object.prototype.toString.call(t)==="[object Object]"){n={};for(e in t)e==="__proto__"?Object.defineProperty(n,e,{value:tt(t[e]),configurable:!0,enumerable:!0,writable:!0}):n[e]=(r=t[e])&&typeof r=="object"?tt(r):r;return n}return t}function Re(t,e,n,r){return it(t,i=>{i.some(l=>l[1][0]===e)&&n(t[e])},r)}var Vr=Symbol(),q=new WeakMap,nt=new WeakMap,De=(t,e)=>{let n=q.get(t);n&&(n[0].forEach(r=>{let{d:i}=r;t!==i&&De(i)}),++n[2],e&&n[3].add(e))},mr=(t,e)=>{let n=q.get(t);return n?.[2]?(n[3].add(e),!0):!1},zt=t=>{let e=q.get(t);e&&(--e[2],e[2]||(e[3].forEach(n=>n()),e[3].clear()),e[0].forEach(n=>{let{d:r}=n;t!==r&&zt(r)}))},vr=t=>{let{s:e,d:n}=t,r=nt.get(n);r||(r=[new Set],nt.set(t.d,r)),r[0].add(t);let i=q.get(e);if(!i){let l=new Set,d=it(e,f=>{l.forEach(s=>{let{d:y,c:w,n:g,i:u}=s;e===y&&f.every(p=>p[1].length===1&&u.includes(p[1][0]))||s.p||(De(e,w),g?zt(e):s.p=Promise.resolve().then(()=>{delete s.p,zt(e)}))})},!0);i=[l,d,0,new Set],q.set(e,i)}i[0].add(t)},Ne=t=>{let{s:e,d:n}=t,r=nt.get(n);r?.[0].delete(t),r?.[0].size===0&&nt.delete(n);let i=q.get(e);if(i){let[l,d]=i;l.delete(t),l.size||(d(),q.delete(e))}},yr=t=>{let e=nt.get(t);return e?Array.from(e[0]):[]};function wr(t,e){let n=e?.proxy||rt({}),r=!!e?.sync,i=Object.keys(t);return i.forEach(l=>{if(Object.getOwnPropertyDescriptor(n,l))throw new Error("object property already defined");let d=t[l],f=null,s=()=>{if(f&&(Array.from(f).map(([u])=>mr(u,s)).some(u=>u)||Array.from(f).every(([u,p])=>Ae(u)===p.v)))return;let y=new Map,w=d(u=>(y.set(u,{v:Ae(u)}),u)),g=()=>{y.forEach((u,p)=>{var o;let a=(o=f?.get(p))==null?void 0:o.s;if(a)u.s=a;else{let c={s:p,d:n,k:l,c:s,n:r,i};vr(c),u.s=c}}),f?.forEach((u,p)=>{!y.has(p)&&u.s&&Ne(u.s)}),f=y};w instanceof Promise?w.finally(g):g(),n[l]=w};s()}),n}function br(t,e){let n=e?.delete?new Set:null;yr(t).forEach(r=>{let{k:i}=r;(!e?.keys||e.keys.includes(i))&&(Ne(r),n&&n.add(i))}),n&&n.forEach(r=>{delete t[r]})}function Er(t){var e;let n=rt({value:"",previousValue:"",event:R({}),context:(e=t.context)!=null?e:R({}),done:!1,tags:[],hasTag(r){return this.tags.includes(r)},matches(...r){return r.includes(this.value)},can(r){return R(this).nextEvents.includes(r)},get nextEvents(){var r,i,l,d;let f=(l=(i=(r=t.states)==null?void 0:r[this.value])==null?void 0:i.on)!=null?l:{},s=(d=t?.on)!=null?d:{};return Object.keys({...f,...s})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return R(n)}function mt(t,e){return(n,r)=>{if(fr(t))return t;if(Vt(t))return t(n,r);if(I(t)){let i=Number.parseFloat(t);if(!Number.isNaN(i))return i;if(e){let l=e?.[t];if(l==null){let d=`[machine] Cannot determine delay for ${t}. It doesn't exist in options.delays`;throw new Error(d)}return Vt(l)?l(n,r):l}}}}function L(t){return I(t)?{type:t}:t}function _(t){return t?X(t)?t:[t]:[]}function We(t){return I(t)?{target:t}:t}function xr(t,e){return(n,r)=>_(t).map(We).find(i=>{var l;let d=Me(i.guard,e)(n,r);return(l=d??i.target)!=null?l:i.actions})}function Sr(t,e){let n=I(t)?We(t):t,r=i=>(i.actions&&!i.target&&e&&(i.target=e),i);if(X(n))return n.map(r);if(et(n))return r(R(n))}var vt=class{constructor(t,e){this.config=t,this.status="Not Started",this.type="machine",this.activityEvents=new Map,this.delayedEvents=new Map,this.stateListeners=new Set,this.eventListeners=new Set,this.doneListeners=new Set,this.contextWatchers=new Set,this.removeStateListener=ke,this.removeEventListener=ke,this.children=new Map,this.start=o=>{if(this.status==="Running")return this;this.status="Running";let a=L("machine.init");if(o){let m=et(o)?o:{context:this.config.context,value:o};this.setState(m.value),this.setContext(m.context)}let c={target:o?void 0:this.config.initial},h=this.getNextStateInfo(c,a);return h.target=R(h.target||c.target),this.initialState=h,this.performStateChangeEffects(h.target,h,a),this.removeStateListener=it(this.state,()=>{this.stateListeners.forEach(m=>{m(this.stateSnapshot)})},this.sync),this.removeEventListener=Re(this.state,"event",m=>{this.config.onEvent&&this.executeActions(this.config.onEvent,m);for(let v of this.eventListeners)v(m)}),this.setupContextWatchers(),this.executeActivities(L("machine.start"),_(this.config.activities),"machine.start"),this.executeActions(this.config.entry,L("machine.start")),this},this.setupContextWatchers=()=>{var o;for(let[a,c]of Object.entries((o=this.config.watch)!=null?o:{}))this.contextWatchers.add(Re(this.state.context,a,()=>{this.executeActions(c,this.state.event)}))},this.setupComputed=()=>{var o;let a=R((o=this.config.computed)!=null?o:{}),c=Object.fromEntries(Object.entries(a).map(([h,m])=>[h,v=>m(v(this.state.context))]));wr(c,{proxy:this.state.context})},this.detachComputed=()=>{br(this.state.context,{delete:!0})},this.stop=()=>{if(this.status!=="Stopped")return this.setState(null),this.setEvent("machine.stop"),this.config.context&&this.setContext(this.config.context),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.stopEventListeners(),this.detachComputed(),this.status="Stopped",this.executeActions(this.config.exit,L("machine.stop")),this},this.stopEventListeners=()=>{this.eventListeners.clear(),this.removeEventListener()},this.stopStateListeners=()=>{this.removeStateListener(),this.stateListeners.clear()},this.stopContextWatchers=()=>{this.contextWatchers.forEach(o=>o()),this.contextWatchers.clear()},this.stopDelayedEvents=()=>{this.delayedEvents.forEach(o=>{o.forEach(a=>a())}),this.delayedEvents.clear()},this.stopActivities=o=>{var a,c;o?((a=this.activityEvents.get(o))==null||a.forEach(h=>h()),(c=this.activityEvents.get(o))==null||c.clear(),this.activityEvents.delete(o)):(this.activityEvents.forEach(h=>{h.forEach(m=>m()),h.clear()}),this.activityEvents.clear())},this.sendChild=(o,a)=>{let c=L(o),h=Ce(a,this.contextSnapshot),m=this.children.get(h);m||jt(`[machine/send-child] Cannot send '${c.type}' event to unknown child`),m.send(c)},this.stopChild=o=>{this.children.has(o)||jt("[machine/stop-child] Cannot stop unknown child"),this.children.get(o).stop(),this.children.delete(o)},this.removeChild=o=>{this.children.delete(o)},this.stopChildren=()=>{this.children.forEach(o=>o.stop()),this.children.clear()},this.setParent=o=>{this.parent=o},this.spawn=(o,a)=>{let c=Ce(o);return a&&(c.id=a),c.type="machine.actor",c.setParent(this),this.children.set(c.id,R(c)),c.onDone(()=>{this.removeChild(c.id)}).start(),R(wt(c))},this.addActivityCleanup=(o,a)=>{var c;!o||(this.activityEvents.has(o)?(c=this.activityEvents.get(o))==null||c.add(a):this.activityEvents.set(o,new Set([a])))},this.setState=o=>{this.state.previousValue=this.state.value,this.state.value=o;let a=this.getStateNode(o);o==null?ur(this.state.tags):this.state.tags=_(a?.tags)},this.setContext=o=>{for(let a in o)this.state.context[a]=o[a]},this.withContext=o=>{this.detachComputed();let a={...this.config.context,...o};return new vt({...this.config,context:a},this.options)},this.withOptions=o=>(this.detachComputed(),new vt(this.config,{...this.options,...o})),this.setActions=o=>{this.actionMap={...this.actionMap,...o}},this.clone=()=>(this.detachComputed(),new vt(this.config,this.options)),this.getStateNode=o=>{var a;if(o)return(a=this.config.states)==null?void 0:a[o]},this.getNextStateInfo=(o,a)=>{var c;let h=this.determineTransition(o,a),m=(c=h?.target)!=null?c:this.state.value,v=this.getStateNode(m);return{transition:h,stateNode:v,target:m}},this.getActionFromDelayedTransition=o=>{let a=L("machine.after"),c=mt(o.delay,this.delayMap)(this.contextSnapshot,a),h;return{entry:()=>{h=globalThis.setTimeout(()=>{let m=this.state.value,v=this.getNextStateInfo(o,a);this.performStateChangeEffects(m,v,a)},c)},exit:()=>{globalThis.clearTimeout(h)}}},this.getDelayedEventActions=o=>{let a=this.getStateNode(o),c=L("machine.after");if(!a||!a.after)return;let h=[],m=[];if(X(a.after)){let v=this.determineTransition(a.after,c);if(!v)return;let b=this.getActionFromDelayedTransition(v);h.push(b.entry),m.push(b.exit)}else if(et(a.after))for(let v in a.after){let b=a.after[v],x={};if(X(b)){let T=this.determineTransition(b,c);T&&(x=T)}else I(b)?x={target:b,delay:v}:x={...b,delay:v};let A=this.getActionFromDelayedTransition(x);h.push(A.entry),m.push(A.exit)}return{entries:h,exits:m}},this.executeActions=(o,a)=>{var c;let h=_t(o,this.guardMap)(this.contextSnapshot,a);for(let m of _(h)){let v=I(m)?(c=this.actionMap)==null?void 0:c[m]:m;Wt(I(m)&&!v,`[machine/exec-action] No implementation found for action: \`${m}\``),v?.(this.state.context,a,this.meta)}},this.executeActivities=(o,a,c)=>{var h;for(let m of a){let v=I(m)?(h=this.activityMap)==null?void 0:h[m]:m;if(!v){Wt(`[machine/exec-activity] No implementation found for activity: \`${m}\``);continue}let b=v(this.state.context,o,this.meta);b&&this.addActivityCleanup(c??this.state.value,b)}},this.createEveryActivities=(o,a)=>{if(!o)return;let c=L("machine.every");if(X(o)){let h=_(o).find(v=>{let b=mt(v.delay,this.delayMap);v.delay=b(this.contextSnapshot,c);let x=Me(v.guard,this.guardMap)(this.contextSnapshot,c);return x??v.delay});if(!h)return;let m=mt(h.delay,this.delayMap)(this.contextSnapshot,c);a(()=>{let v=globalThis.setInterval(()=>{this.executeActions(h.actions,c)},m);return()=>{globalThis.clearInterval(v)}})}else for(let h in o){let m=o?.[h],v=mt(h,this.delayMap)(this.contextSnapshot,c);a(()=>{let b=globalThis.setInterval(()=>{this.executeActions(m,c)},v);return()=>{globalThis.clearInterval(b)}})}},this.setEvent=o=>{this.state.event=wt(L(o))},this.performExitEffects=(o,a)=>{let c=this.state.value,h=o?this.getStateNode(o):void 0;this.stopActivities(c);let m=_t(h?.exit,this.guardMap)(this.contextSnapshot,a),v=_(m),b=this.delayedEvents.get(c);b&&v.push(...b),this.executeActions(v,a),this.eventListeners.clear()},this.performEntryEffects=(o,a)=>{let c=this.getStateNode(o),h=_(c?.activities);this.createEveryActivities(c?.every,x=>{h.unshift(x)}),h.length>0&&this.executeActivities(a,h);let m=_t(c?.entry,this.guardMap)(this.contextSnapshot,a),v=_(m),b=this.getDelayedEventActions(o);c?.after&&b&&(this.delayedEvents.set(o,b?.exits),v.push(...b.entries)),this.executeActions(v,a),c?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(x=>{x(this.stateSnapshot)}),this.stop())},this.performTransitionEffects=(o,a)=>{let c=this.determineTransition(o,a);this.executeActions(c?.actions,a)},this.performStateChangeEffects=(o,a,c)=>{var h,m;this.setEvent(c),a.target=(m=(h=a.target)!=null?h:this.state.value)!=null?m:void 0;let v=a.target&&a.target!==this.state.value;v&&this.performExitEffects(o,c),this.performTransitionEffects(a?.transition,c),this.setState(a.target),v&&this.performEntryEffects(a.target,c)},this.determineTransition=(o,a)=>{let c=xr(o,this.guardMap);return c?.(this.contextSnapshot,a)},this.sendParent=o=>{var a;this.parent||jt("[machine/send-parent] Cannot send event to an unknown parent");let c=L(o);(a=this.parent)==null||a.send(c)},this.send=o=>{let a=L(o);this.transition(this.state.value,a)},this.transition=(o,a)=>{var c,h,m;let v=I(o)?this.getStateNode(o):o?.stateNode,b=L(a);if(!v&&!this.config.on){let O=this.status==="Stopped"?"[machine/transition] Cannot transition a stopped machine":"[machine/transition] State does not have a definition";Wt(O);return}let x=(m=(c=v?.on)==null?void 0:c[b.type])!=null?m:(h=this.config.on)==null?void 0:h[b.type],A=Sr(x,this.state.value);if(!A)return;let T=this.getNextStateInfo(A,b);return this.performStateChangeEffects(this.state.value,T,b),T.stateNode},this.subscribe=o=>(this.stateListeners.add(o),this.status==="Running"&&o(this.stateSnapshot),()=>{this.stateListeners.delete(o)}),this.onDone=o=>(this.doneListeners.add(o),this),this.onTransition=o=>(this.stateListeners.add(o),this.status==="Running"&&o(this.stateSnapshot),this),this.onEvent=o=>(o(this.state.event),this.eventListeners.add(o),this);var n,r,i,l,d,f,s,y,w,g,u;this.options=tt(e),this.id=(n=t.id)!=null?n:`machine-${dr()}`,this.guardMap=(i=(r=this.options)==null?void 0:r.guards)!=null?i:{},this.actionMap=(d=(l=this.options)==null?void 0:l.actions)!=null?d:{},this.delayMap=(s=(f=this.options)==null?void 0:f.delays)!=null?s:{},this.activityMap=(w=(y=this.options)==null?void 0:y.activities)!=null?w:{},this.sync=(u=(g=this.options)==null?void 0:g.sync)!=null?u:!1,this.state=Er(tt(t)),this.setupComputed();let p=L("machine.created");this.executeActions(t?.created,p)}get stateSnapshot(){return R(cr(this.state))}get contextSnapshot(){return this.stateSnapshot.context}get self(){let t=this;return{id:this.id,send:this.send.bind(this),sendParent:this.sendParent.bind(this),sendChild:this.sendChild.bind(this),stop:this.stop.bind(this),stopChild:this.stopChild.bind(this),spawn:this.spawn.bind(this),get state(){return t.stateSnapshot}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),listen:this.onEvent.bind(this),self:this.self,getState:()=>this.stateSnapshot}}},je=(t,e)=>new vt(t,e);var P=rt({id:null,prevId:null,setId(t){this.prevId=this.id,this.id=t}});function _e(t,e,n=Ee){let r=t.context.id,i=t.context.hasAriaLabel,l=t.hasTag("open"),d=E.getTriggerId(t.context),f=E.getContentId(t.context),s=be({measured:!!t.context.isPlacementComplete});return{isOpen:l,open(){e("OPEN")},close(){e("CLOSE")},getAnimationState(){return{enter:P.prevId===null&&r===P.id,exit:P.id===null}},triggerProps:n.button({"data-part":"trigger",id:d,"data-expanded":$t(l),"aria-describedby":l?f:void 0,onClick(){e("CLICK")},onFocus(){e("FOCUS")},onBlur(){r===P.id&&e("BLUR")},onPointerDown(){r===P.id&&e("POINTER_DOWN")},onPointerMove(){e("POINTER_ENTER")},onPointerLeave(){e("POINTER_LEAVE")},onPointerCancel(){e("POINTER_LEAVE")}}),arrowProps:n.element({id:E.getArrowId(t.context),"data-part":"arrow",style:s.arrow}),innerArrowProps:n.element({"data-part":"arrow-inner",style:s.innerArrow}),positionerProps:n.element({id:E.getPositionerId(t.context),"data-part":"positioner",style:s.floating}),contentProps:n.element({"data-part":"content",role:i?void 0:"tooltip",id:i?void 0:f,"data-placement":t.context.currentPlacement,onPointerEnter(){e("TOOLTIP_POINTER_ENTER")},onPointerLeave(){e("TOOLTIP_POINTER_LEAVE")},style:{pointerEvents:t.context.interactive?"auto":"none"}}),labelProps:n.element({"data-part":"label",id:f,role:"tooltip",style:Zt,children:t.context["aria-label"]}),createPortal(){let y=E.getDoc(t.context),w=E.getPortalEl(t.context);if(w)return w;let g=E.createPortalEl(t.context);return y.body.appendChild(g),g}}}var He=()=>{};var Qr=(()=>{let t=0;return()=>(t++,t.toString(36))})();var Pr=t=>Lr()&&t.test(navigator.userAgent);var Lr=()=>typeof window<"u";var Ve=()=>Pr(/^((?!chrome|android).)*safari/i);var ze=je({id:"tooltip",initial:"unknown",context:{id:"",openDelay:1e3,closeDelay:500,closeOnPointerDown:!0,closeOnEsc:!0,interactive:!0,positioning:{placement:"bottom"},currentPlacement:void 0},computed:{hasAriaLabel:t=>!!t["aria-label"]},on:{OPEN:"open",CLOSE:"closed"},states:{unknown:{on:{SETUP:{target:"closed",actions:"setupDocument"}}},closed:{tags:["closed"],entry:["clearGlobalId","invokeOnClose"],on:{FOCUS:"open",POINTER_ENTER:[{guard:"noVisibleTooltip",target:"opening"},{target:"open"}]}},opening:{tags:["closed"],activities:["trackScroll","trackPointerlockChange"],after:{OPEN_DELAY:"open"},on:{POINTER_LEAVE:"closed",BLUR:"closed",SCROLL:"closed",POINTER_LOCK_CHANGE:"closed",POINTER_DOWN:{guard:"closeOnPointerDown",target:"closed"}}},open:{tags:["open"],activities:["trackEscapeKey","trackDisabledTriggerOnSafari","trackScroll","trackPointerlockChange","computePlacement"],entry:["setGlobalId","invokeOnOpen"],on:{POINTER_LEAVE:[{guard:"isVisible",target:"closing"},{target:"closed"}],BLUR:"closed",ESCAPE:"closed",SCROLL:"closed",POINTER_LOCK_CHANGE:"closed",TOOLTIP_POINTER_LEAVE:{guard:"isInteractive",target:"closing"},POINTER_DOWN:{guard:"closeOnPointerDown",target:"closed"},CLICK:"closed"}},closing:{tags:["open"],activities:["trackStore","computePlacement"],after:{CLOSE_DELAY:"closed"},on:{FORCE_CLOSE:"closed",POINTER_ENTER:"open",TOOLTIP_POINTER_ENTER:{guard:"isInteractive",target:"open"}}}}},{activities:{computePlacement(t){t.currentPlacement=t.positioning.placement;let e;return qt(()=>{e=we(E.getTriggerEl(t),E.getPositionerEl(t),{...t.positioning,onComplete(n){t.currentPlacement=n.placement,t.isPlacementComplete=!0},onCleanup(){t.currentPlacement=void 0,t.isPlacementComplete=!1}})}),e},trackPointerlockChange(t,e,{send:n}){return Qt(E.getDoc(t),()=>{n("POINTER_LOCK_CHANGE")})},trackScroll(t,e,{send:n}){let r=E.getTriggerEl(t);if(!r)return;let i=Ot(r).map(l=>at(l,"scroll",()=>n("SCROLL"),{passive:!0,capture:!0}));return()=>{i.forEach(l=>l==null?void 0:l())}},trackStore(t,e,{send:n}){return it(P,()=>{P.id!==t.id&&n("FORCE_CLOSE")})},trackDisabledTriggerOnSafari(t,e,{send:n}){if(!Ve())return He;let r=E.getDoc(t);return Yt(r,"pointermove",i=>{let l="[data-part=trigger][data-expanded]";Tt(i.target)&&i.target.closest(l)||n("POINTER_LEAVE")})},trackEscapeKey(t,e,{send:n}){if(!t.closeOnEsc)return;let r=E.getDoc(t);return at(r,"keydown",i=>{i.key==="Escape"&&n("ESCAPE")})}},actions:{setupDocument(t,e){t.id=e.id,e.doc&&(t.doc=wt(e.doc))},setGlobalId(t){P.setId(t.id)},clearGlobalId(t){t.id===P.id&&P.setId(null)},invokeOnOpen(t,e){var r;["TOOLTIP_POINTER_ENTER","POINTER_ENTER"].includes(e.type)||(r=t.onOpen)==null||r.call(t)},invokeOnClose(t,e){var r;["SETUP"].includes(e.type)||(r=t.onClose)==null||r.call(t)}},guards:{closeOnPointerDown:t=>t.closeOnPointerDown,noVisibleTooltip:()=>P.id===null,isVisible:t=>t.id===P.id,isInteractive:t=>t.interactive},delays:{OPEN_DELAY:t=>t.openDelay,CLOSE_DELAY:t=>t.closeDelay}});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
|
+
};
|
|
38
|
+
var __copyProps = (to, from, except, desc) => {
|
|
39
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(from))
|
|
41
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
42
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
43
|
+
}
|
|
44
|
+
return to;
|
|
45
|
+
};
|
|
46
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
47
|
+
var __async = (__this, __arguments, generator) => {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
var fulfilled = (value) => {
|
|
50
|
+
try {
|
|
51
|
+
step(generator.next(value));
|
|
52
|
+
} catch (e) {
|
|
53
|
+
reject(e);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var rejected = (value) => {
|
|
57
|
+
try {
|
|
58
|
+
step(generator.throw(value));
|
|
59
|
+
} catch (e) {
|
|
60
|
+
reject(e);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
64
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/index.ts
|
|
69
|
+
var src_exports = {};
|
|
70
|
+
__export(src_exports, {
|
|
71
|
+
connect: () => connect,
|
|
72
|
+
machine: () => machine
|
|
73
|
+
});
|
|
74
|
+
module.exports = __toCommonJS(src_exports);
|
|
75
|
+
|
|
76
|
+
// ../../utilities/dom/src/attrs.ts
|
|
77
|
+
var dataAttr = (guard) => {
|
|
78
|
+
return guard ? "" : void 0;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// ../../utilities/dom/src/computed-style.ts
|
|
82
|
+
var styleCache = /* @__PURE__ */ new WeakMap();
|
|
83
|
+
function getComputedStyle2(el) {
|
|
84
|
+
var _a;
|
|
85
|
+
if (!el)
|
|
86
|
+
return {};
|
|
87
|
+
let style = styleCache.get(el);
|
|
88
|
+
if (!style) {
|
|
89
|
+
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
90
|
+
style = win.getComputedStyle(el);
|
|
91
|
+
styleCache.set(el, style);
|
|
92
|
+
}
|
|
93
|
+
return style;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ../../utilities/dom/src/next-tick.ts
|
|
97
|
+
function raf(fn) {
|
|
98
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
99
|
+
return function cleanup() {
|
|
100
|
+
globalThis.cancelAnimationFrame(id);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ../../utilities/core/src/array.ts
|
|
105
|
+
function clear(v) {
|
|
106
|
+
while (v.length > 0)
|
|
107
|
+
v.pop();
|
|
108
|
+
return v;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ../../utilities/core/src/functions.ts
|
|
112
|
+
var runIfFn = (v, ...a) => {
|
|
113
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
114
|
+
return res != null ? res : void 0;
|
|
115
|
+
};
|
|
116
|
+
var cast = (v) => v;
|
|
117
|
+
var noop = () => {
|
|
118
|
+
};
|
|
119
|
+
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
120
|
+
var uuid = /* @__PURE__ */ (() => {
|
|
121
|
+
let id = 0;
|
|
122
|
+
return () => {
|
|
123
|
+
id++;
|
|
124
|
+
return id.toString(36);
|
|
125
|
+
};
|
|
126
|
+
})();
|
|
127
|
+
|
|
128
|
+
// ../../utilities/core/src/guard.ts
|
|
129
|
+
var ua = (v) => isDom() && v.test(navigator.userAgent);
|
|
130
|
+
var isDom = () => !!(typeof window !== "undefined");
|
|
131
|
+
var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
|
|
132
|
+
var isArray = (v) => Array.isArray(v);
|
|
133
|
+
var isBoolean = (v) => v === true || v === false;
|
|
134
|
+
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
135
|
+
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
136
|
+
var isString = (v) => typeof v === "string";
|
|
137
|
+
var isFunction = (v) => typeof v === "function";
|
|
138
|
+
|
|
139
|
+
// ../../utilities/core/src/warning.ts
|
|
140
|
+
function warn(...a) {
|
|
141
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
142
|
+
const c = a.length === 2 ? a[0] : true;
|
|
143
|
+
if (c && void 0 !== "production") {
|
|
144
|
+
console.warn(m);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function invariant(...a) {
|
|
148
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
149
|
+
const c = a.length === 2 ? a[0] : true;
|
|
150
|
+
if (c && void 0 !== "production") {
|
|
151
|
+
throw new Error(m);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ../../utilities/dom/src/event-bus.ts
|
|
156
|
+
var listenerElements = /* @__PURE__ */ new Map();
|
|
157
|
+
var listenerCache = /* @__PURE__ */ new Map();
|
|
158
|
+
function globalEventBus(node, type, handler, options) {
|
|
159
|
+
var _a;
|
|
160
|
+
if (!node)
|
|
161
|
+
return noop;
|
|
162
|
+
const hash2 = JSON.stringify({ type, options });
|
|
163
|
+
const group = listenerElements.get(node);
|
|
164
|
+
if (!listenerElements.has(node)) {
|
|
165
|
+
const group2 = /* @__PURE__ */ new Map([[hash2, /* @__PURE__ */ new Set([handler])]]);
|
|
166
|
+
listenerElements.set(node, group2);
|
|
167
|
+
} else if (group == null ? void 0 : group.has(hash2)) {
|
|
168
|
+
(_a = group == null ? void 0 : group.get(hash2)) == null ? void 0 : _a.add(handler);
|
|
169
|
+
} else {
|
|
170
|
+
group == null ? void 0 : group.set(hash2, /* @__PURE__ */ new Set([handler]));
|
|
171
|
+
}
|
|
172
|
+
function attach(node2) {
|
|
173
|
+
var _a2, _b;
|
|
174
|
+
function listener(event) {
|
|
175
|
+
var _a3;
|
|
176
|
+
const group2 = listenerElements.get(node2);
|
|
177
|
+
(_a3 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
178
|
+
}
|
|
179
|
+
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
180
|
+
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash2, listener]]));
|
|
181
|
+
node2.addEventListener(type, listener, options);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash2))) {
|
|
185
|
+
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash2, listener);
|
|
186
|
+
node2.addEventListener(type, listener, options);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
attach(node);
|
|
190
|
+
return function remove() {
|
|
191
|
+
var _a2, _b, _c, _d;
|
|
192
|
+
if (!listenerElements.has(node))
|
|
193
|
+
return;
|
|
194
|
+
const group2 = listenerElements.get(node);
|
|
195
|
+
(_a2 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a2.delete(handler);
|
|
196
|
+
if (((_b = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _b.size) === 0) {
|
|
197
|
+
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash2);
|
|
198
|
+
node.removeEventListener(type, listener, options);
|
|
199
|
+
group2 == null ? void 0 : group2.delete(hash2);
|
|
200
|
+
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash2);
|
|
201
|
+
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
202
|
+
listenerElements.delete(node);
|
|
203
|
+
listenerCache.delete(node);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ../../utilities/dom/src/listener.ts
|
|
210
|
+
var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
|
|
211
|
+
var isRef = (v) => t(v) === "Object" && "current" in v;
|
|
212
|
+
var runIfFn2 = (fn) => t(fn) === "Function" ? fn() : fn;
|
|
213
|
+
var isTouchEvent = (v) => t(v) === "Object" && !!v.touches;
|
|
214
|
+
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
215
|
+
function extractInfo(event, type = "page") {
|
|
216
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
|
|
217
|
+
return {
|
|
218
|
+
point: {
|
|
219
|
+
x: point[`${type}X`],
|
|
220
|
+
y: point[`${type}Y`]
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function addDomEvent(target, event, listener, options) {
|
|
225
|
+
const node = isRef(target) ? target.current : runIfFn2(target);
|
|
226
|
+
return globalEventBus(node, event, listener, options);
|
|
227
|
+
}
|
|
228
|
+
function addPointerEvent(target, event, listener, options) {
|
|
229
|
+
var _a;
|
|
230
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
231
|
+
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
232
|
+
}
|
|
233
|
+
function wrapHandler(fn, filter = false) {
|
|
234
|
+
const listener = (event) => {
|
|
235
|
+
fn(event, extractInfo(event));
|
|
236
|
+
};
|
|
237
|
+
return filter ? filterPrimaryPointer(listener) : listener;
|
|
238
|
+
}
|
|
239
|
+
function filterPrimaryPointer(fn) {
|
|
240
|
+
return (event) => {
|
|
241
|
+
var _a;
|
|
242
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
243
|
+
const isMouseEvent = event instanceof win.MouseEvent;
|
|
244
|
+
const isPrimary = !isMouseEvent || isMouseEvent && event.button === 0;
|
|
245
|
+
if (isPrimary)
|
|
246
|
+
fn(event);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
var supportsPointerEvent = () => typeof window !== "undefined" && window.onpointerdown === null;
|
|
250
|
+
var supportsTouchEvent = () => typeof window !== "undefined" && window.ontouchstart === null;
|
|
251
|
+
var supportsMouseEvent = () => typeof window !== "undefined" && window.onmousedown === null;
|
|
252
|
+
var mouseEventNames = {
|
|
253
|
+
pointerdown: "mousedown",
|
|
254
|
+
pointermove: "mousemove",
|
|
255
|
+
pointerup: "mouseup",
|
|
256
|
+
pointercancel: "mousecancel",
|
|
257
|
+
pointerover: "mouseover",
|
|
258
|
+
pointerout: "mouseout",
|
|
259
|
+
pointerenter: "mouseenter",
|
|
260
|
+
pointerleave: "mouseleave"
|
|
261
|
+
};
|
|
262
|
+
var touchEventNames = {
|
|
263
|
+
pointerdown: "touchstart",
|
|
264
|
+
pointermove: "touchmove",
|
|
265
|
+
pointerup: "touchend",
|
|
266
|
+
pointercancel: "touchcancel"
|
|
267
|
+
};
|
|
268
|
+
function getEventName(evt) {
|
|
269
|
+
if (supportsPointerEvent())
|
|
270
|
+
return evt;
|
|
271
|
+
if (supportsTouchEvent())
|
|
272
|
+
return touchEventNames[evt];
|
|
273
|
+
if (supportsMouseEvent())
|
|
274
|
+
return mouseEventNames[evt];
|
|
275
|
+
return evt;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ../../utilities/dom/src/query.ts
|
|
279
|
+
function getOwnerDocument(el) {
|
|
280
|
+
var _a;
|
|
281
|
+
if (isWindow(el))
|
|
282
|
+
return el.document;
|
|
283
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
284
|
+
}
|
|
285
|
+
function getOwnerWindow(el) {
|
|
286
|
+
var _a;
|
|
287
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
288
|
+
}
|
|
289
|
+
function getNodeName(node) {
|
|
290
|
+
return isWindow(node) ? "" : node ? node.localName || "" : "";
|
|
291
|
+
}
|
|
292
|
+
function getParent(el) {
|
|
293
|
+
const doc = getOwnerDocument(el);
|
|
294
|
+
if (getNodeName(el) === "html")
|
|
295
|
+
return el;
|
|
296
|
+
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
297
|
+
}
|
|
298
|
+
function isHTMLElement(v) {
|
|
299
|
+
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
300
|
+
}
|
|
301
|
+
function isWindow(value) {
|
|
302
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ../../utilities/dom/src/scrollable.ts
|
|
306
|
+
function isScrollParent(el) {
|
|
307
|
+
const { overflow, overflowX, overflowY } = getComputedStyle2(el);
|
|
308
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
309
|
+
}
|
|
310
|
+
function getScrollParent(el) {
|
|
311
|
+
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
312
|
+
return getOwnerDocument(el).body;
|
|
313
|
+
}
|
|
314
|
+
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
315
|
+
return el;
|
|
316
|
+
}
|
|
317
|
+
return getScrollParent(getParent(el));
|
|
318
|
+
}
|
|
319
|
+
function getScrollParents(el, list = []) {
|
|
320
|
+
const scrollParent = getScrollParent(el);
|
|
321
|
+
const isBody = scrollParent === getOwnerDocument(el).body;
|
|
322
|
+
const win = getOwnerWindow(scrollParent);
|
|
323
|
+
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
324
|
+
const parents = list.concat(target);
|
|
325
|
+
if (isBody)
|
|
326
|
+
return parents;
|
|
327
|
+
return parents.concat(getScrollParents(getParent(target)));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// ../../utilities/dom/src/visually-hidden.ts
|
|
331
|
+
var visuallyHiddenStyle = {
|
|
332
|
+
border: "0",
|
|
333
|
+
clip: "rect(0 0 0 0)",
|
|
334
|
+
height: "1px",
|
|
335
|
+
margin: "-1px",
|
|
336
|
+
overflow: "hidden",
|
|
337
|
+
padding: "0",
|
|
338
|
+
position: "absolute",
|
|
339
|
+
width: "1px",
|
|
340
|
+
whiteSpace: "nowrap",
|
|
341
|
+
wordWrap: "normal"
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
// ../../utilities/dom/src/pointerlock.ts
|
|
345
|
+
function addPointerlockChangeListener(doc, fn) {
|
|
346
|
+
return addDomEvent(doc, "pointerlockchange", fn, false);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ../../utilities/dom/src/rect-observer.ts
|
|
350
|
+
var observedElements = /* @__PURE__ */ new Map();
|
|
351
|
+
function observeElementRect(el, fn) {
|
|
352
|
+
const data = observedElements.get(el);
|
|
353
|
+
if (!data) {
|
|
354
|
+
observedElements.set(el, { rect: {}, callbacks: [fn] });
|
|
355
|
+
if (observedElements.size === 1) {
|
|
356
|
+
rafId = requestAnimationFrame(runLoop);
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
data.callbacks.push(fn);
|
|
360
|
+
fn(el.getBoundingClientRect());
|
|
361
|
+
}
|
|
362
|
+
return function unobserve() {
|
|
363
|
+
const data2 = observedElements.get(el);
|
|
364
|
+
if (!data2)
|
|
365
|
+
return;
|
|
366
|
+
const index = data2.callbacks.indexOf(fn);
|
|
367
|
+
if (index > -1) {
|
|
368
|
+
data2.callbacks.splice(index, 1);
|
|
369
|
+
}
|
|
370
|
+
if (data2.callbacks.length === 0) {
|
|
371
|
+
observedElements.delete(el);
|
|
372
|
+
if (observedElements.size === 0) {
|
|
373
|
+
cancelAnimationFrame(rafId);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
var rafId;
|
|
379
|
+
function runLoop() {
|
|
380
|
+
const changedRectsData = [];
|
|
381
|
+
observedElements.forEach((data, element) => {
|
|
382
|
+
const newRect = element.getBoundingClientRect();
|
|
383
|
+
if (!isEqual(data.rect, newRect)) {
|
|
384
|
+
data.rect = newRect;
|
|
385
|
+
changedRectsData.push(data);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
changedRectsData.forEach((data) => {
|
|
389
|
+
data.callbacks.forEach((callback) => callback(data.rect));
|
|
390
|
+
});
|
|
391
|
+
rafId = requestAnimationFrame(runLoop);
|
|
392
|
+
}
|
|
393
|
+
function isEqual(rect1, rect2) {
|
|
394
|
+
return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ../../../node_modules/@floating-ui/core/dist/floating-ui.core.esm.js
|
|
398
|
+
function getSide(placement) {
|
|
399
|
+
return placement.split("-")[0];
|
|
400
|
+
}
|
|
401
|
+
function getAlignment(placement) {
|
|
402
|
+
return placement.split("-")[1];
|
|
403
|
+
}
|
|
404
|
+
function getMainAxisFromPlacement(placement) {
|
|
405
|
+
return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
|
|
406
|
+
}
|
|
407
|
+
function getLengthFromAxis(axis) {
|
|
408
|
+
return axis === "y" ? "height" : "width";
|
|
409
|
+
}
|
|
410
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
411
|
+
let {
|
|
412
|
+
reference,
|
|
413
|
+
floating
|
|
414
|
+
} = _ref;
|
|
415
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
416
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
417
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
418
|
+
const length = getLengthFromAxis(mainAxis);
|
|
419
|
+
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
420
|
+
const side = getSide(placement);
|
|
421
|
+
const isVertical = mainAxis === "x";
|
|
422
|
+
let coords;
|
|
423
|
+
switch (side) {
|
|
424
|
+
case "top":
|
|
425
|
+
coords = {
|
|
426
|
+
x: commonX,
|
|
427
|
+
y: reference.y - floating.height
|
|
428
|
+
};
|
|
429
|
+
break;
|
|
430
|
+
case "bottom":
|
|
431
|
+
coords = {
|
|
432
|
+
x: commonX,
|
|
433
|
+
y: reference.y + reference.height
|
|
434
|
+
};
|
|
435
|
+
break;
|
|
436
|
+
case "right":
|
|
437
|
+
coords = {
|
|
438
|
+
x: reference.x + reference.width,
|
|
439
|
+
y: commonY
|
|
440
|
+
};
|
|
441
|
+
break;
|
|
442
|
+
case "left":
|
|
443
|
+
coords = {
|
|
444
|
+
x: reference.x - floating.width,
|
|
445
|
+
y: commonY
|
|
446
|
+
};
|
|
447
|
+
break;
|
|
448
|
+
default:
|
|
449
|
+
coords = {
|
|
450
|
+
x: reference.x,
|
|
451
|
+
y: reference.y
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
switch (getAlignment(placement)) {
|
|
455
|
+
case "start":
|
|
456
|
+
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
457
|
+
break;
|
|
458
|
+
case "end":
|
|
459
|
+
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
return coords;
|
|
463
|
+
}
|
|
464
|
+
var computePosition = (reference, floating, config) => __async(void 0, null, function* () {
|
|
465
|
+
const {
|
|
466
|
+
placement = "bottom",
|
|
467
|
+
strategy = "absolute",
|
|
468
|
+
middleware = [],
|
|
469
|
+
platform: platform2
|
|
470
|
+
} = config;
|
|
471
|
+
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating);
|
|
472
|
+
if (void 0 !== "production") {
|
|
473
|
+
if (platform2 == null) {
|
|
474
|
+
console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
|
|
475
|
+
}
|
|
476
|
+
if (middleware.filter((_ref) => {
|
|
477
|
+
let {
|
|
478
|
+
name
|
|
479
|
+
} = _ref;
|
|
480
|
+
return name === "autoPlacement" || name === "flip";
|
|
481
|
+
}).length > 1) {
|
|
482
|
+
throw new Error(["Floating UI: duplicate `flip` and/or `autoPlacement`", "middleware detected. This will lead to an infinite loop. Ensure only", "one of either has been passed to the `middleware` array."].join(" "));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
let rects = yield platform2.getElementRects({
|
|
486
|
+
reference,
|
|
487
|
+
floating,
|
|
488
|
+
strategy
|
|
489
|
+
});
|
|
490
|
+
let {
|
|
491
|
+
x,
|
|
492
|
+
y
|
|
493
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
494
|
+
let statefulPlacement = placement;
|
|
495
|
+
let middlewareData = {};
|
|
496
|
+
let _debug_loop_count_ = 0;
|
|
497
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
498
|
+
if (void 0 !== "production") {
|
|
499
|
+
_debug_loop_count_++;
|
|
500
|
+
if (_debug_loop_count_ > 100) {
|
|
501
|
+
throw new Error(["Floating UI: The middleware lifecycle appears to be", "running in an infinite loop. This is usually caused by a `reset`", "continually being returned without a break condition."].join(" "));
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const {
|
|
505
|
+
name,
|
|
506
|
+
fn
|
|
507
|
+
} = middleware[i];
|
|
508
|
+
const {
|
|
509
|
+
x: nextX,
|
|
510
|
+
y: nextY,
|
|
511
|
+
data,
|
|
512
|
+
reset
|
|
513
|
+
} = yield fn({
|
|
514
|
+
x,
|
|
515
|
+
y,
|
|
516
|
+
initialPlacement: placement,
|
|
517
|
+
placement: statefulPlacement,
|
|
518
|
+
strategy,
|
|
519
|
+
middlewareData,
|
|
520
|
+
rects,
|
|
521
|
+
platform: platform2,
|
|
522
|
+
elements: {
|
|
523
|
+
reference,
|
|
524
|
+
floating
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
x = nextX != null ? nextX : x;
|
|
528
|
+
y = nextY != null ? nextY : y;
|
|
529
|
+
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
|
|
530
|
+
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
|
|
531
|
+
});
|
|
532
|
+
if (reset) {
|
|
533
|
+
if (typeof reset === "object") {
|
|
534
|
+
if (reset.placement) {
|
|
535
|
+
statefulPlacement = reset.placement;
|
|
536
|
+
}
|
|
537
|
+
if (reset.rects) {
|
|
538
|
+
rects = reset.rects === true ? yield platform2.getElementRects({
|
|
539
|
+
reference,
|
|
540
|
+
floating,
|
|
541
|
+
strategy
|
|
542
|
+
}) : reset.rects;
|
|
543
|
+
}
|
|
544
|
+
({
|
|
545
|
+
x,
|
|
546
|
+
y
|
|
547
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
548
|
+
}
|
|
549
|
+
i = -1;
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
x,
|
|
555
|
+
y,
|
|
556
|
+
placement: statefulPlacement,
|
|
557
|
+
strategy,
|
|
558
|
+
middlewareData
|
|
559
|
+
};
|
|
560
|
+
});
|
|
561
|
+
function expandPaddingObject(padding) {
|
|
562
|
+
return __spreadValues({
|
|
563
|
+
top: 0,
|
|
564
|
+
right: 0,
|
|
565
|
+
bottom: 0,
|
|
566
|
+
left: 0
|
|
567
|
+
}, padding);
|
|
568
|
+
}
|
|
569
|
+
function getSideObjectFromPadding(padding) {
|
|
570
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
571
|
+
top: padding,
|
|
572
|
+
right: padding,
|
|
573
|
+
bottom: padding,
|
|
574
|
+
left: padding
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function rectToClientRect(rect) {
|
|
578
|
+
return __spreadProps(__spreadValues({}, rect), {
|
|
579
|
+
top: rect.y,
|
|
580
|
+
left: rect.x,
|
|
581
|
+
right: rect.x + rect.width,
|
|
582
|
+
bottom: rect.y + rect.height
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function detectOverflow(middlewareArguments, options) {
|
|
586
|
+
return __async(this, null, function* () {
|
|
587
|
+
var _await$platform$isEle;
|
|
588
|
+
if (options === void 0) {
|
|
589
|
+
options = {};
|
|
590
|
+
}
|
|
591
|
+
const {
|
|
592
|
+
x,
|
|
593
|
+
y,
|
|
594
|
+
platform: platform2,
|
|
595
|
+
rects,
|
|
596
|
+
elements,
|
|
597
|
+
strategy
|
|
598
|
+
} = middlewareArguments;
|
|
599
|
+
const {
|
|
600
|
+
boundary = "clippingAncestors",
|
|
601
|
+
rootBoundary = "viewport",
|
|
602
|
+
elementContext = "floating",
|
|
603
|
+
altBoundary = false,
|
|
604
|
+
padding = 0
|
|
605
|
+
} = options;
|
|
606
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
607
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
608
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
609
|
+
const clippingClientRect = rectToClientRect(yield platform2.getClippingRect({
|
|
610
|
+
element: ((_await$platform$isEle = yield platform2.isElement == null ? void 0 : platform2.isElement(element)) != null ? _await$platform$isEle : true) ? element : element.contextElement || (yield platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
611
|
+
boundary,
|
|
612
|
+
rootBoundary,
|
|
613
|
+
strategy
|
|
614
|
+
}));
|
|
615
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
616
|
+
rect: elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
|
|
617
|
+
x,
|
|
618
|
+
y
|
|
619
|
+
}) : rects.reference,
|
|
620
|
+
offsetParent: yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating),
|
|
621
|
+
strategy
|
|
622
|
+
}) : rects[elementContext]);
|
|
623
|
+
return {
|
|
624
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
625
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
626
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
627
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
628
|
+
};
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
var min = Math.min;
|
|
632
|
+
var max = Math.max;
|
|
633
|
+
function within(min$1, value, max$1) {
|
|
634
|
+
return max(min$1, min(value, max$1));
|
|
635
|
+
}
|
|
636
|
+
var arrow = (options) => ({
|
|
637
|
+
name: "arrow",
|
|
638
|
+
options,
|
|
639
|
+
fn(middlewareArguments) {
|
|
640
|
+
return __async(this, null, function* () {
|
|
641
|
+
const {
|
|
642
|
+
element,
|
|
643
|
+
padding = 0
|
|
644
|
+
} = options != null ? options : {};
|
|
645
|
+
const {
|
|
646
|
+
x,
|
|
647
|
+
y,
|
|
648
|
+
placement,
|
|
649
|
+
rects,
|
|
650
|
+
platform: platform2
|
|
651
|
+
} = middlewareArguments;
|
|
652
|
+
if (element == null) {
|
|
653
|
+
if (void 0 !== "production") {
|
|
654
|
+
console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
|
|
655
|
+
}
|
|
656
|
+
return {};
|
|
657
|
+
}
|
|
658
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
659
|
+
const coords = {
|
|
660
|
+
x,
|
|
661
|
+
y
|
|
662
|
+
};
|
|
663
|
+
const axis = getMainAxisFromPlacement(placement);
|
|
664
|
+
const length = getLengthFromAxis(axis);
|
|
665
|
+
const arrowDimensions = yield platform2.getDimensions(element);
|
|
666
|
+
const minProp = axis === "y" ? "top" : "left";
|
|
667
|
+
const maxProp = axis === "y" ? "bottom" : "right";
|
|
668
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
669
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
670
|
+
const arrowOffsetParent = yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element);
|
|
671
|
+
const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
672
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
673
|
+
const min3 = paddingObject[minProp];
|
|
674
|
+
const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
675
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
676
|
+
const offset2 = within(min3, center, max3);
|
|
677
|
+
return {
|
|
678
|
+
data: {
|
|
679
|
+
[axis]: offset2,
|
|
680
|
+
centerOffset: center - offset2
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
var hash$1 = {
|
|
687
|
+
left: "right",
|
|
688
|
+
right: "left",
|
|
689
|
+
bottom: "top",
|
|
690
|
+
top: "bottom"
|
|
691
|
+
};
|
|
692
|
+
function getOppositePlacement(placement) {
|
|
693
|
+
return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
|
|
694
|
+
}
|
|
695
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
696
|
+
if (rtl === void 0) {
|
|
697
|
+
rtl = false;
|
|
698
|
+
}
|
|
699
|
+
const alignment = getAlignment(placement);
|
|
700
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
701
|
+
const length = getLengthFromAxis(mainAxis);
|
|
702
|
+
let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
703
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
704
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
705
|
+
}
|
|
706
|
+
return {
|
|
707
|
+
main: mainAlignmentSide,
|
|
708
|
+
cross: getOppositePlacement(mainAlignmentSide)
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
var hash = {
|
|
712
|
+
start: "end",
|
|
713
|
+
end: "start"
|
|
714
|
+
};
|
|
715
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
716
|
+
return placement.replace(/start|end/g, (matched) => hash[matched]);
|
|
717
|
+
}
|
|
718
|
+
function getExpandedPlacements(placement) {
|
|
719
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
720
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
721
|
+
}
|
|
722
|
+
var flip = function(options) {
|
|
723
|
+
if (options === void 0) {
|
|
724
|
+
options = {};
|
|
725
|
+
}
|
|
726
|
+
return {
|
|
727
|
+
name: "flip",
|
|
728
|
+
options,
|
|
729
|
+
fn(middlewareArguments) {
|
|
730
|
+
return __async(this, null, function* () {
|
|
731
|
+
var _middlewareData$flip;
|
|
732
|
+
const {
|
|
733
|
+
placement,
|
|
734
|
+
middlewareData,
|
|
735
|
+
rects,
|
|
736
|
+
initialPlacement,
|
|
737
|
+
platform: platform2,
|
|
738
|
+
elements
|
|
739
|
+
} = middlewareArguments;
|
|
740
|
+
const _a2 = options, {
|
|
741
|
+
mainAxis: checkMainAxis = true,
|
|
742
|
+
crossAxis: checkCrossAxis = true,
|
|
743
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
744
|
+
fallbackStrategy = "bestFit",
|
|
745
|
+
flipAlignment = true
|
|
746
|
+
} = _a2, detectOverflowOptions = __objRest(_a2, [
|
|
747
|
+
"mainAxis",
|
|
748
|
+
"crossAxis",
|
|
749
|
+
"fallbackPlacements",
|
|
750
|
+
"fallbackStrategy",
|
|
751
|
+
"flipAlignment"
|
|
752
|
+
]);
|
|
753
|
+
const side = getSide(placement);
|
|
754
|
+
const isBasePlacement = side === initialPlacement;
|
|
755
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
756
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
757
|
+
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
758
|
+
const overflows = [];
|
|
759
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
760
|
+
if (checkMainAxis) {
|
|
761
|
+
overflows.push(overflow[side]);
|
|
762
|
+
}
|
|
763
|
+
if (checkCrossAxis) {
|
|
764
|
+
const {
|
|
765
|
+
main,
|
|
766
|
+
cross
|
|
767
|
+
} = getAlignmentSides(placement, rects, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
768
|
+
overflows.push(overflow[main], overflow[cross]);
|
|
769
|
+
}
|
|
770
|
+
overflowsData = [...overflowsData, {
|
|
771
|
+
placement,
|
|
772
|
+
overflows
|
|
773
|
+
}];
|
|
774
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
775
|
+
var _middlewareData$flip$, _middlewareData$flip2;
|
|
776
|
+
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
777
|
+
const nextPlacement = placements[nextIndex];
|
|
778
|
+
if (nextPlacement) {
|
|
779
|
+
return {
|
|
780
|
+
data: {
|
|
781
|
+
index: nextIndex,
|
|
782
|
+
overflows: overflowsData
|
|
783
|
+
},
|
|
784
|
+
reset: {
|
|
785
|
+
placement: nextPlacement
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
let resetPlacement = "bottom";
|
|
790
|
+
switch (fallbackStrategy) {
|
|
791
|
+
case "bestFit": {
|
|
792
|
+
var _overflowsData$slice$;
|
|
793
|
+
const placement2 = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0) - b.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;
|
|
794
|
+
if (placement2) {
|
|
795
|
+
resetPlacement = placement2;
|
|
796
|
+
}
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
case "initialPlacement":
|
|
800
|
+
resetPlacement = initialPlacement;
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
if (placement !== resetPlacement) {
|
|
804
|
+
return {
|
|
805
|
+
reset: {
|
|
806
|
+
placement: resetPlacement
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return {};
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
};
|
|
816
|
+
function convertValueToCoords(placement, rects, value, rtl) {
|
|
817
|
+
if (rtl === void 0) {
|
|
818
|
+
rtl = false;
|
|
819
|
+
}
|
|
820
|
+
const side = getSide(placement);
|
|
821
|
+
const alignment = getAlignment(placement);
|
|
822
|
+
const isVertical = getMainAxisFromPlacement(placement) === "x";
|
|
823
|
+
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
|
824
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
825
|
+
const rawValue = typeof value === "function" ? value(__spreadProps(__spreadValues({}, rects), {
|
|
826
|
+
placement
|
|
827
|
+
})) : value;
|
|
828
|
+
const isNumber2 = typeof rawValue === "number";
|
|
829
|
+
let {
|
|
830
|
+
mainAxis,
|
|
831
|
+
crossAxis,
|
|
832
|
+
alignmentAxis
|
|
833
|
+
} = isNumber2 ? {
|
|
834
|
+
mainAxis: rawValue,
|
|
835
|
+
crossAxis: 0,
|
|
836
|
+
alignmentAxis: null
|
|
837
|
+
} : __spreadValues({
|
|
838
|
+
mainAxis: 0,
|
|
839
|
+
crossAxis: 0,
|
|
840
|
+
alignmentAxis: null
|
|
841
|
+
}, rawValue);
|
|
842
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
843
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
844
|
+
}
|
|
845
|
+
return isVertical ? {
|
|
846
|
+
x: crossAxis * crossAxisMulti,
|
|
847
|
+
y: mainAxis * mainAxisMulti
|
|
848
|
+
} : {
|
|
849
|
+
x: mainAxis * mainAxisMulti,
|
|
850
|
+
y: crossAxis * crossAxisMulti
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
var offset = function(value) {
|
|
854
|
+
if (value === void 0) {
|
|
855
|
+
value = 0;
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
name: "offset",
|
|
859
|
+
options: value,
|
|
860
|
+
fn(middlewareArguments) {
|
|
861
|
+
return __async(this, null, function* () {
|
|
862
|
+
const {
|
|
863
|
+
x,
|
|
864
|
+
y,
|
|
865
|
+
placement,
|
|
866
|
+
rects,
|
|
867
|
+
platform: platform2,
|
|
868
|
+
elements
|
|
869
|
+
} = middlewareArguments;
|
|
870
|
+
const diffCoords = convertValueToCoords(placement, rects, value, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
871
|
+
return {
|
|
872
|
+
x: x + diffCoords.x,
|
|
873
|
+
y: y + diffCoords.y,
|
|
874
|
+
data: diffCoords
|
|
875
|
+
};
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
function getCrossAxis(axis) {
|
|
881
|
+
return axis === "x" ? "y" : "x";
|
|
882
|
+
}
|
|
883
|
+
var shift = function(options) {
|
|
884
|
+
if (options === void 0) {
|
|
885
|
+
options = {};
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
name: "shift",
|
|
889
|
+
options,
|
|
890
|
+
fn(middlewareArguments) {
|
|
891
|
+
return __async(this, null, function* () {
|
|
892
|
+
const {
|
|
893
|
+
x,
|
|
894
|
+
y,
|
|
895
|
+
placement
|
|
896
|
+
} = middlewareArguments;
|
|
897
|
+
const _a2 = options, {
|
|
898
|
+
mainAxis: checkMainAxis = true,
|
|
899
|
+
crossAxis: checkCrossAxis = false,
|
|
900
|
+
limiter = {
|
|
901
|
+
fn: (_ref) => {
|
|
902
|
+
let {
|
|
903
|
+
x: x2,
|
|
904
|
+
y: y2
|
|
905
|
+
} = _ref;
|
|
906
|
+
return {
|
|
907
|
+
x: x2,
|
|
908
|
+
y: y2
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
} = _a2, detectOverflowOptions = __objRest(_a2, [
|
|
913
|
+
"mainAxis",
|
|
914
|
+
"crossAxis",
|
|
915
|
+
"limiter"
|
|
916
|
+
]);
|
|
917
|
+
const coords = {
|
|
918
|
+
x,
|
|
919
|
+
y
|
|
920
|
+
};
|
|
921
|
+
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
922
|
+
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
923
|
+
const crossAxis = getCrossAxis(mainAxis);
|
|
924
|
+
let mainAxisCoord = coords[mainAxis];
|
|
925
|
+
let crossAxisCoord = coords[crossAxis];
|
|
926
|
+
if (checkMainAxis) {
|
|
927
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
928
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
929
|
+
const min3 = mainAxisCoord + overflow[minSide];
|
|
930
|
+
const max3 = mainAxisCoord - overflow[maxSide];
|
|
931
|
+
mainAxisCoord = within(min3, mainAxisCoord, max3);
|
|
932
|
+
}
|
|
933
|
+
if (checkCrossAxis) {
|
|
934
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
935
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
936
|
+
const min3 = crossAxisCoord + overflow[minSide];
|
|
937
|
+
const max3 = crossAxisCoord - overflow[maxSide];
|
|
938
|
+
crossAxisCoord = within(min3, crossAxisCoord, max3);
|
|
939
|
+
}
|
|
940
|
+
const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, middlewareArguments), {
|
|
941
|
+
[mainAxis]: mainAxisCoord,
|
|
942
|
+
[crossAxis]: crossAxisCoord
|
|
943
|
+
}));
|
|
944
|
+
return __spreadProps(__spreadValues({}, limitedCoords), {
|
|
945
|
+
data: {
|
|
946
|
+
x: limitedCoords.x - x,
|
|
947
|
+
y: limitedCoords.y - y
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
};
|
|
954
|
+
var size = function(options) {
|
|
955
|
+
if (options === void 0) {
|
|
956
|
+
options = {};
|
|
957
|
+
}
|
|
958
|
+
return {
|
|
959
|
+
name: "size",
|
|
960
|
+
options,
|
|
961
|
+
fn(middlewareArguments) {
|
|
962
|
+
return __async(this, null, function* () {
|
|
963
|
+
const {
|
|
964
|
+
placement,
|
|
965
|
+
rects,
|
|
966
|
+
platform: platform2,
|
|
967
|
+
elements
|
|
968
|
+
} = middlewareArguments;
|
|
969
|
+
const _a2 = options, {
|
|
970
|
+
apply
|
|
971
|
+
} = _a2, detectOverflowOptions = __objRest(_a2, [
|
|
972
|
+
"apply"
|
|
973
|
+
]);
|
|
974
|
+
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
975
|
+
const side = getSide(placement);
|
|
976
|
+
const alignment = getAlignment(placement);
|
|
977
|
+
let heightSide;
|
|
978
|
+
let widthSide;
|
|
979
|
+
if (side === "top" || side === "bottom") {
|
|
980
|
+
heightSide = side;
|
|
981
|
+
widthSide = alignment === ((yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
982
|
+
} else {
|
|
983
|
+
widthSide = side;
|
|
984
|
+
heightSide = alignment === "end" ? "top" : "bottom";
|
|
985
|
+
}
|
|
986
|
+
const xMin = max(overflow.left, 0);
|
|
987
|
+
const xMax = max(overflow.right, 0);
|
|
988
|
+
const yMin = max(overflow.top, 0);
|
|
989
|
+
const yMax = max(overflow.bottom, 0);
|
|
990
|
+
const dimensions = {
|
|
991
|
+
height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
|
|
992
|
+
width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
|
|
993
|
+
};
|
|
994
|
+
const prevDimensions = yield platform2.getDimensions(elements.floating);
|
|
995
|
+
apply == null ? void 0 : apply(__spreadValues(__spreadValues({}, dimensions), rects));
|
|
996
|
+
const nextDimensions = yield platform2.getDimensions(elements.floating);
|
|
997
|
+
if (prevDimensions.width !== nextDimensions.width || prevDimensions.height !== nextDimensions.height) {
|
|
998
|
+
return {
|
|
999
|
+
reset: {
|
|
1000
|
+
rects: true
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
return {};
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// ../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
|
|
1011
|
+
function isWindow2(value) {
|
|
1012
|
+
return value && value.document && value.location && value.alert && value.setInterval;
|
|
1013
|
+
}
|
|
1014
|
+
function getWindow(node) {
|
|
1015
|
+
if (node == null) {
|
|
1016
|
+
return window;
|
|
1017
|
+
}
|
|
1018
|
+
if (!isWindow2(node)) {
|
|
1019
|
+
const ownerDocument = node.ownerDocument;
|
|
1020
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
1021
|
+
}
|
|
1022
|
+
return node;
|
|
1023
|
+
}
|
|
1024
|
+
function getComputedStyle$1(element) {
|
|
1025
|
+
return getWindow(element).getComputedStyle(element);
|
|
1026
|
+
}
|
|
1027
|
+
function getNodeName2(node) {
|
|
1028
|
+
return isWindow2(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
|
|
1029
|
+
}
|
|
1030
|
+
function isHTMLElement2(value) {
|
|
1031
|
+
return value instanceof getWindow(value).HTMLElement;
|
|
1032
|
+
}
|
|
1033
|
+
function isElement(value) {
|
|
1034
|
+
return value instanceof getWindow(value).Element;
|
|
1035
|
+
}
|
|
1036
|
+
function isNode(value) {
|
|
1037
|
+
return value instanceof getWindow(value).Node;
|
|
1038
|
+
}
|
|
1039
|
+
function isShadowRoot(node) {
|
|
1040
|
+
const OwnElement = getWindow(node).ShadowRoot;
|
|
1041
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
1042
|
+
}
|
|
1043
|
+
function isOverflowElement(element) {
|
|
1044
|
+
const {
|
|
1045
|
+
overflow,
|
|
1046
|
+
overflowX,
|
|
1047
|
+
overflowY
|
|
1048
|
+
} = getComputedStyle$1(element);
|
|
1049
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
1050
|
+
}
|
|
1051
|
+
function isTableElement(element) {
|
|
1052
|
+
return ["table", "td", "th"].includes(getNodeName2(element));
|
|
1053
|
+
}
|
|
1054
|
+
function isContainingBlock(element) {
|
|
1055
|
+
const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
|
|
1056
|
+
const css = getComputedStyle$1(element);
|
|
1057
|
+
return css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].includes(css.willChange) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false);
|
|
1058
|
+
}
|
|
1059
|
+
function isLayoutViewport() {
|
|
1060
|
+
return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1061
|
+
}
|
|
1062
|
+
var min2 = Math.min;
|
|
1063
|
+
var max2 = Math.max;
|
|
1064
|
+
var round = Math.round;
|
|
1065
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
1066
|
+
if (includeScale === void 0) {
|
|
1067
|
+
includeScale = false;
|
|
1068
|
+
}
|
|
1069
|
+
if (isFixedStrategy === void 0) {
|
|
1070
|
+
isFixedStrategy = false;
|
|
1071
|
+
}
|
|
1072
|
+
const clientRect = element.getBoundingClientRect();
|
|
1073
|
+
let scaleX = 1;
|
|
1074
|
+
let scaleY = 1;
|
|
1075
|
+
if (includeScale && isHTMLElement2(element)) {
|
|
1076
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
1077
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
1078
|
+
}
|
|
1079
|
+
const win = isElement(element) ? getWindow(element) : window;
|
|
1080
|
+
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
1081
|
+
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
|
|
1082
|
+
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
|
|
1083
|
+
const width = clientRect.width / scaleX;
|
|
1084
|
+
const height = clientRect.height / scaleY;
|
|
1085
|
+
return {
|
|
1086
|
+
width,
|
|
1087
|
+
height,
|
|
1088
|
+
top: y,
|
|
1089
|
+
right: x + width,
|
|
1090
|
+
bottom: y + height,
|
|
1091
|
+
left: x,
|
|
1092
|
+
x,
|
|
1093
|
+
y
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
function getDocumentElement(node) {
|
|
1097
|
+
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
1098
|
+
}
|
|
1099
|
+
function getNodeScroll(element) {
|
|
1100
|
+
if (isElement(element)) {
|
|
1101
|
+
return {
|
|
1102
|
+
scrollLeft: element.scrollLeft,
|
|
1103
|
+
scrollTop: element.scrollTop
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
return {
|
|
1107
|
+
scrollLeft: element.pageXOffset,
|
|
1108
|
+
scrollTop: element.pageYOffset
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
function getWindowScrollBarX(element) {
|
|
1112
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
1113
|
+
}
|
|
1114
|
+
function isScaled(element) {
|
|
1115
|
+
const rect = getBoundingClientRect(element);
|
|
1116
|
+
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
|
1117
|
+
}
|
|
1118
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1119
|
+
const isOffsetParentAnElement = isHTMLElement2(offsetParent);
|
|
1120
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1121
|
+
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === "fixed");
|
|
1122
|
+
let scroll = {
|
|
1123
|
+
scrollLeft: 0,
|
|
1124
|
+
scrollTop: 0
|
|
1125
|
+
};
|
|
1126
|
+
const offsets = {
|
|
1127
|
+
x: 0,
|
|
1128
|
+
y: 0
|
|
1129
|
+
};
|
|
1130
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
1131
|
+
if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1132
|
+
scroll = getNodeScroll(offsetParent);
|
|
1133
|
+
}
|
|
1134
|
+
if (isHTMLElement2(offsetParent)) {
|
|
1135
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1136
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1137
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1138
|
+
} else if (documentElement) {
|
|
1139
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
return {
|
|
1143
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1144
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1145
|
+
width: rect.width,
|
|
1146
|
+
height: rect.height
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
function getParentNode(node) {
|
|
1150
|
+
if (getNodeName2(node) === "html") {
|
|
1151
|
+
return node;
|
|
1152
|
+
}
|
|
1153
|
+
return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
|
|
1154
|
+
}
|
|
1155
|
+
function getTrueOffsetParent(element) {
|
|
1156
|
+
if (!isHTMLElement2(element) || getComputedStyle(element).position === "fixed") {
|
|
1157
|
+
return null;
|
|
1158
|
+
}
|
|
1159
|
+
return element.offsetParent;
|
|
1160
|
+
}
|
|
1161
|
+
function getContainingBlock(element) {
|
|
1162
|
+
let currentNode = getParentNode(element);
|
|
1163
|
+
if (isShadowRoot(currentNode)) {
|
|
1164
|
+
currentNode = currentNode.host;
|
|
1165
|
+
}
|
|
1166
|
+
while (isHTMLElement2(currentNode) && !["html", "body"].includes(getNodeName2(currentNode))) {
|
|
1167
|
+
if (isContainingBlock(currentNode)) {
|
|
1168
|
+
return currentNode;
|
|
1169
|
+
} else {
|
|
1170
|
+
currentNode = currentNode.parentNode;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return null;
|
|
1174
|
+
}
|
|
1175
|
+
function getOffsetParent(element) {
|
|
1176
|
+
const window2 = getWindow(element);
|
|
1177
|
+
let offsetParent = getTrueOffsetParent(element);
|
|
1178
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
|
1179
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
1180
|
+
}
|
|
1181
|
+
if (offsetParent && (getNodeName2(offsetParent) === "html" || getNodeName2(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
|
|
1182
|
+
return window2;
|
|
1183
|
+
}
|
|
1184
|
+
return offsetParent || getContainingBlock(element) || window2;
|
|
1185
|
+
}
|
|
1186
|
+
function getDimensions(element) {
|
|
1187
|
+
if (isHTMLElement2(element)) {
|
|
1188
|
+
return {
|
|
1189
|
+
width: element.offsetWidth,
|
|
1190
|
+
height: element.offsetHeight
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
const rect = getBoundingClientRect(element);
|
|
1194
|
+
return {
|
|
1195
|
+
width: rect.width,
|
|
1196
|
+
height: rect.height
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1200
|
+
let {
|
|
1201
|
+
rect,
|
|
1202
|
+
offsetParent,
|
|
1203
|
+
strategy
|
|
1204
|
+
} = _ref;
|
|
1205
|
+
const isOffsetParentAnElement = isHTMLElement2(offsetParent);
|
|
1206
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1207
|
+
if (offsetParent === documentElement) {
|
|
1208
|
+
return rect;
|
|
1209
|
+
}
|
|
1210
|
+
let scroll = {
|
|
1211
|
+
scrollLeft: 0,
|
|
1212
|
+
scrollTop: 0
|
|
1213
|
+
};
|
|
1214
|
+
const offsets = {
|
|
1215
|
+
x: 0,
|
|
1216
|
+
y: 0
|
|
1217
|
+
};
|
|
1218
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
1219
|
+
if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1220
|
+
scroll = getNodeScroll(offsetParent);
|
|
1221
|
+
}
|
|
1222
|
+
if (isHTMLElement2(offsetParent)) {
|
|
1223
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1224
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1225
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return __spreadProps(__spreadValues({}, rect), {
|
|
1229
|
+
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
1230
|
+
y: rect.y - scroll.scrollTop + offsets.y
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
function getViewportRect(element, strategy) {
|
|
1234
|
+
const win = getWindow(element);
|
|
1235
|
+
const html = getDocumentElement(element);
|
|
1236
|
+
const visualViewport = win.visualViewport;
|
|
1237
|
+
let width = html.clientWidth;
|
|
1238
|
+
let height = html.clientHeight;
|
|
1239
|
+
let x = 0;
|
|
1240
|
+
let y = 0;
|
|
1241
|
+
if (visualViewport) {
|
|
1242
|
+
width = visualViewport.width;
|
|
1243
|
+
height = visualViewport.height;
|
|
1244
|
+
const layoutViewport = isLayoutViewport();
|
|
1245
|
+
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
|
1246
|
+
x = visualViewport.offsetLeft;
|
|
1247
|
+
y = visualViewport.offsetTop;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return {
|
|
1251
|
+
width,
|
|
1252
|
+
height,
|
|
1253
|
+
x,
|
|
1254
|
+
y
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
function getDocumentRect(element) {
|
|
1258
|
+
var _element$ownerDocumen;
|
|
1259
|
+
const html = getDocumentElement(element);
|
|
1260
|
+
const scroll = getNodeScroll(element);
|
|
1261
|
+
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
1262
|
+
const width = max2(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
1263
|
+
const height = max2(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
1264
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1265
|
+
const y = -scroll.scrollTop;
|
|
1266
|
+
if (getComputedStyle$1(body || html).direction === "rtl") {
|
|
1267
|
+
x += max2(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
1268
|
+
}
|
|
1269
|
+
return {
|
|
1270
|
+
width,
|
|
1271
|
+
height,
|
|
1272
|
+
x,
|
|
1273
|
+
y
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
function getNearestOverflowAncestor(node) {
|
|
1277
|
+
const parentNode = getParentNode(node);
|
|
1278
|
+
if (["html", "body", "#document"].includes(getNodeName2(parentNode))) {
|
|
1279
|
+
return node.ownerDocument.body;
|
|
1280
|
+
}
|
|
1281
|
+
if (isHTMLElement2(parentNode) && isOverflowElement(parentNode)) {
|
|
1282
|
+
return parentNode;
|
|
1283
|
+
}
|
|
1284
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1285
|
+
}
|
|
1286
|
+
function getOverflowAncestors(node, list) {
|
|
1287
|
+
var _node$ownerDocument;
|
|
1288
|
+
if (list === void 0) {
|
|
1289
|
+
list = [];
|
|
1290
|
+
}
|
|
1291
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1292
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
1293
|
+
const win = getWindow(scrollableAncestor);
|
|
1294
|
+
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
1295
|
+
const updatedList = list.concat(target);
|
|
1296
|
+
return isBody ? updatedList : updatedList.concat(getOverflowAncestors(getParentNode(target)));
|
|
1297
|
+
}
|
|
1298
|
+
function contains(parent, child) {
|
|
1299
|
+
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
|
|
1300
|
+
if (parent.contains(child)) {
|
|
1301
|
+
return true;
|
|
1302
|
+
} else if (rootNode && isShadowRoot(rootNode)) {
|
|
1303
|
+
let next = child;
|
|
1304
|
+
do {
|
|
1305
|
+
if (next && parent === next) {
|
|
1306
|
+
return true;
|
|
1307
|
+
}
|
|
1308
|
+
next = next.parentNode || next.host;
|
|
1309
|
+
} while (next);
|
|
1310
|
+
}
|
|
1311
|
+
return false;
|
|
1312
|
+
}
|
|
1313
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1314
|
+
const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
|
|
1315
|
+
const top = clientRect.top + element.clientTop;
|
|
1316
|
+
const left = clientRect.left + element.clientLeft;
|
|
1317
|
+
return {
|
|
1318
|
+
top,
|
|
1319
|
+
left,
|
|
1320
|
+
x: left,
|
|
1321
|
+
y: top,
|
|
1322
|
+
right: left + element.clientWidth,
|
|
1323
|
+
bottom: top + element.clientHeight,
|
|
1324
|
+
width: element.clientWidth,
|
|
1325
|
+
height: element.clientHeight
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
|
1329
|
+
if (clippingParent === "viewport") {
|
|
1330
|
+
return rectToClientRect(getViewportRect(element, strategy));
|
|
1331
|
+
}
|
|
1332
|
+
if (isElement(clippingParent)) {
|
|
1333
|
+
return getInnerBoundingClientRect(clippingParent, strategy);
|
|
1334
|
+
}
|
|
1335
|
+
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
1336
|
+
}
|
|
1337
|
+
function getClippingAncestors(element) {
|
|
1338
|
+
const clippingAncestors = getOverflowAncestors(element);
|
|
1339
|
+
const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element).position);
|
|
1340
|
+
const clipperElement = canEscapeClipping && isHTMLElement2(element) ? getOffsetParent(element) : element;
|
|
1341
|
+
if (!isElement(clipperElement)) {
|
|
1342
|
+
return [];
|
|
1343
|
+
}
|
|
1344
|
+
return clippingAncestors.filter((clippingAncestors2) => isElement(clippingAncestors2) && contains(clippingAncestors2, clipperElement) && getNodeName2(clippingAncestors2) !== "body");
|
|
1345
|
+
}
|
|
1346
|
+
function getClippingRect(_ref) {
|
|
1347
|
+
let {
|
|
1348
|
+
element,
|
|
1349
|
+
boundary,
|
|
1350
|
+
rootBoundary,
|
|
1351
|
+
strategy
|
|
1352
|
+
} = _ref;
|
|
1353
|
+
const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
|
|
1354
|
+
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
|
|
1355
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1356
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1357
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1358
|
+
accRect.top = max2(rect.top, accRect.top);
|
|
1359
|
+
accRect.right = min2(rect.right, accRect.right);
|
|
1360
|
+
accRect.bottom = min2(rect.bottom, accRect.bottom);
|
|
1361
|
+
accRect.left = max2(rect.left, accRect.left);
|
|
1362
|
+
return accRect;
|
|
1363
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1364
|
+
return {
|
|
1365
|
+
width: clippingRect.right - clippingRect.left,
|
|
1366
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1367
|
+
x: clippingRect.left,
|
|
1368
|
+
y: clippingRect.top
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
var platform = {
|
|
1372
|
+
getClippingRect,
|
|
1373
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1374
|
+
isElement,
|
|
1375
|
+
getDimensions,
|
|
1376
|
+
getOffsetParent,
|
|
1377
|
+
getDocumentElement,
|
|
1378
|
+
getElementRects: (_ref) => {
|
|
1379
|
+
let {
|
|
1380
|
+
reference,
|
|
1381
|
+
floating,
|
|
1382
|
+
strategy
|
|
1383
|
+
} = _ref;
|
|
1384
|
+
return {
|
|
1385
|
+
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
1386
|
+
floating: __spreadProps(__spreadValues({}, getDimensions(floating)), {
|
|
1387
|
+
x: 0,
|
|
1388
|
+
y: 0
|
|
1389
|
+
})
|
|
1390
|
+
};
|
|
1391
|
+
},
|
|
1392
|
+
getClientRects: (element) => Array.from(element.getClientRects()),
|
|
1393
|
+
isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
|
|
1394
|
+
};
|
|
1395
|
+
var computePosition2 = (reference, floating, options) => computePosition(reference, floating, __spreadValues({
|
|
1396
|
+
platform
|
|
1397
|
+
}, options));
|
|
1398
|
+
|
|
1399
|
+
// ../../utilities/popper/src/auto-update.ts
|
|
1400
|
+
function resolveOptions(option) {
|
|
1401
|
+
if (isBoolean(option))
|
|
1402
|
+
return { ancestorResize: option, ancestorScroll: option, referenceResize: option };
|
|
1403
|
+
return Object.assign({ ancestorResize: true, ancestorScroll: true, referenceResize: true }, option);
|
|
1404
|
+
}
|
|
1405
|
+
function autoUpdate(reference, floating, update, options = false) {
|
|
1406
|
+
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
|
|
1407
|
+
const useAncestors = ancestorScroll || ancestorResize;
|
|
1408
|
+
const ancestors = [];
|
|
1409
|
+
if (useAncestors && isHTMLElement(reference)) {
|
|
1410
|
+
ancestors.push(...getOverflowAncestors(reference));
|
|
1411
|
+
}
|
|
1412
|
+
function addResizeListeners() {
|
|
1413
|
+
let cleanups = [observeElementRect(floating, update)];
|
|
1414
|
+
if (referenceResize && isHTMLElement(reference)) {
|
|
1415
|
+
cleanups.push(observeElementRect(reference, update));
|
|
1416
|
+
}
|
|
1417
|
+
cleanups.push(pipe(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
1418
|
+
return () => cleanups.forEach((fn) => fn());
|
|
1419
|
+
}
|
|
1420
|
+
function addScrollListeners() {
|
|
1421
|
+
return pipe(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
|
|
1422
|
+
}
|
|
1423
|
+
return pipe(addResizeListeners(), addScrollListeners());
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// ../../utilities/popper/src/middleware.ts
|
|
1427
|
+
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
1428
|
+
var cssVars = {
|
|
1429
|
+
arrowShadowColor: toVar("--arrow-shadow-color"),
|
|
1430
|
+
arrowSize: toVar("--arrow-size"),
|
|
1431
|
+
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
1432
|
+
arrowBg: toVar("--arrow-background"),
|
|
1433
|
+
transformOrigin: toVar("--transform-origin"),
|
|
1434
|
+
arrowOffset: toVar("--arrow-offset"),
|
|
1435
|
+
boxShadow: toVar("--arrow-box-shadow")
|
|
1436
|
+
};
|
|
1437
|
+
var transforms = {
|
|
1438
|
+
top: "bottom center",
|
|
1439
|
+
"top-start": "bottom left",
|
|
1440
|
+
"top-end": "bottom right",
|
|
1441
|
+
bottom: "top center",
|
|
1442
|
+
"bottom-start": "top left",
|
|
1443
|
+
"bottom-end": "top right",
|
|
1444
|
+
left: "right center",
|
|
1445
|
+
"left-start": "right top",
|
|
1446
|
+
"left-end": "right bottom",
|
|
1447
|
+
right: "left center",
|
|
1448
|
+
"right-start": "left top",
|
|
1449
|
+
"right-end": "left bottom"
|
|
1450
|
+
};
|
|
1451
|
+
var transformOrigin = {
|
|
1452
|
+
name: "transformOrigin",
|
|
1453
|
+
fn({ placement, elements }) {
|
|
1454
|
+
const { floating } = elements;
|
|
1455
|
+
floating.style.setProperty(cssVars.transformOrigin.variable, transforms[placement]);
|
|
1456
|
+
return {
|
|
1457
|
+
data: { transformOrigin: transforms[placement] }
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
var shiftArrow = (opts) => ({
|
|
1462
|
+
name: "shiftArrow",
|
|
1463
|
+
fn({ placement, middlewareData }) {
|
|
1464
|
+
var _a;
|
|
1465
|
+
const { element: arrow2 } = opts;
|
|
1466
|
+
const { x, y } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
|
|
1467
|
+
const staticSide = {
|
|
1468
|
+
top: "bottom",
|
|
1469
|
+
right: "left",
|
|
1470
|
+
bottom: "top",
|
|
1471
|
+
left: "right"
|
|
1472
|
+
}[placement.split("-")[0]];
|
|
1473
|
+
Object.assign(arrow2.style, {
|
|
1474
|
+
top: `${y}px`,
|
|
1475
|
+
left: `${x}px`,
|
|
1476
|
+
[staticSide]: cssVars.arrowOffset.reference,
|
|
1477
|
+
[cssVars.boxShadow.variable]: getBoxShadow(placement)
|
|
1478
|
+
});
|
|
1479
|
+
return {};
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
function getBoxShadow(placement) {
|
|
1483
|
+
if (placement.includes("top"))
|
|
1484
|
+
return `1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1485
|
+
if (placement.includes("bottom"))
|
|
1486
|
+
return `-1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1487
|
+
if (placement.includes("right"))
|
|
1488
|
+
return `-1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1489
|
+
if (placement.includes("left"))
|
|
1490
|
+
return `1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
// ../../utilities/popper/src/get-placement.ts
|
|
1494
|
+
var defaultOptions = {
|
|
1495
|
+
strategy: "absolute",
|
|
1496
|
+
placement: "bottom",
|
|
1497
|
+
listeners: true,
|
|
1498
|
+
gutter: 8,
|
|
1499
|
+
flip: true,
|
|
1500
|
+
sameWidth: false
|
|
1501
|
+
};
|
|
1502
|
+
function getPlacement(reference, floating, options = {}) {
|
|
1503
|
+
var _a;
|
|
1504
|
+
if (reference == null || floating == null)
|
|
1505
|
+
return noop;
|
|
1506
|
+
options = Object.assign({}, defaultOptions, options);
|
|
1507
|
+
const middleware = [transformOrigin];
|
|
1508
|
+
if (options.flip) {
|
|
1509
|
+
middleware.push(flip({ boundary: options.boundary, padding: 8 }));
|
|
1510
|
+
}
|
|
1511
|
+
if (options.gutter || options.offset) {
|
|
1512
|
+
const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
|
|
1513
|
+
middleware.push(offset(data));
|
|
1514
|
+
}
|
|
1515
|
+
middleware.push(shift({ boundary: options.boundary }));
|
|
1516
|
+
const doc = getOwnerDocument(floating);
|
|
1517
|
+
const arrowEl = doc.querySelector("[data-part=arrow]");
|
|
1518
|
+
if (arrowEl) {
|
|
1519
|
+
middleware.push(arrow({ element: arrowEl, padding: 8 }), shiftArrow({ element: arrowEl }));
|
|
1520
|
+
}
|
|
1521
|
+
if (options.sameWidth) {
|
|
1522
|
+
middleware.push(size({
|
|
1523
|
+
apply(data) {
|
|
1524
|
+
const { width } = data.reference;
|
|
1525
|
+
Object.assign(floating.style, { width: `${width}px`, minWidth: "unset" });
|
|
1526
|
+
}
|
|
1527
|
+
}));
|
|
1528
|
+
}
|
|
1529
|
+
function compute() {
|
|
1530
|
+
if (reference == null || floating == null)
|
|
1531
|
+
return;
|
|
1532
|
+
const { placement, strategy } = options;
|
|
1533
|
+
computePosition2(reference, floating, { placement, middleware, strategy }).then((data) => {
|
|
1534
|
+
const { x, y, strategy: strategy2 } = data;
|
|
1535
|
+
Object.assign(floating.style, { left: `${x}px`, top: `${y}px`, position: strategy2 });
|
|
1536
|
+
return data;
|
|
1537
|
+
}).then((data) => {
|
|
1538
|
+
var _a2;
|
|
1539
|
+
(_a2 = options.onComplete) == null ? void 0 : _a2.call(options, data);
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
compute();
|
|
1543
|
+
return pipe(autoUpdate(reference, floating, compute, options.listeners), (_a = options.onCleanup) != null ? _a : noop);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// ../../utilities/popper/src/get-styles.ts
|
|
1547
|
+
var UNMEASURED_FLOATING_STYLE = {
|
|
1548
|
+
position: "fixed",
|
|
1549
|
+
top: 0,
|
|
1550
|
+
left: 0,
|
|
1551
|
+
opacity: 0,
|
|
1552
|
+
transform: "translate3d(0, -200%, 0)",
|
|
1553
|
+
pointerEvents: "none"
|
|
1554
|
+
};
|
|
1555
|
+
function getPlacementStyles(options) {
|
|
1556
|
+
const { measured, strategy = "absolute" } = options;
|
|
1557
|
+
return {
|
|
1558
|
+
arrow: {
|
|
1559
|
+
position: "absolute",
|
|
1560
|
+
width: cssVars.arrowSize.reference,
|
|
1561
|
+
height: cssVars.arrowSize.reference,
|
|
1562
|
+
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
1563
|
+
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
|
|
1564
|
+
opacity: !measured ? 0 : void 0
|
|
1565
|
+
},
|
|
1566
|
+
innerArrow: {
|
|
1567
|
+
transform: "rotate(45deg)",
|
|
1568
|
+
background: cssVars.arrowBg.reference,
|
|
1569
|
+
top: "0",
|
|
1570
|
+
left: "0",
|
|
1571
|
+
width: "100%",
|
|
1572
|
+
height: "100%",
|
|
1573
|
+
position: "absolute",
|
|
1574
|
+
zIndex: "inherit"
|
|
1575
|
+
},
|
|
1576
|
+
floating: __spreadValues({
|
|
1577
|
+
position: strategy,
|
|
1578
|
+
minWidth: "max-content"
|
|
1579
|
+
}, !measured && UNMEASURED_FLOATING_STYLE)
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
// ../../types/src/prop-types.ts
|
|
1584
|
+
function createNormalizer(fn) {
|
|
1585
|
+
return { button: fn, label: fn, input: fn, output: fn, element: fn };
|
|
1586
|
+
}
|
|
1587
|
+
var normalizeProp = createNormalizer((v) => v);
|
|
1588
|
+
|
|
1589
|
+
// src/tooltip.dom.ts
|
|
1590
|
+
var dom = {
|
|
1591
|
+
getDoc: (ctx) => ctx.doc || document,
|
|
1592
|
+
getWin: (ctx) => {
|
|
1593
|
+
var _a;
|
|
1594
|
+
return ((_a = ctx.doc) == null ? void 0 : _a.defaultView) || window;
|
|
1595
|
+
},
|
|
1596
|
+
getTriggerId: (ctx) => {
|
|
1597
|
+
var _a, _b;
|
|
1598
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tooltip-${ctx.id}--trigger`;
|
|
1599
|
+
},
|
|
1600
|
+
getContentId: (ctx) => {
|
|
1601
|
+
var _a, _b;
|
|
1602
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tooltip-${ctx.id}--content`;
|
|
1603
|
+
},
|
|
1604
|
+
getArrowId: (ctx) => `tooltip-${ctx.id}--arrow`,
|
|
1605
|
+
getPositionerId: (ctx) => `tooltip-${ctx.id}--popper`,
|
|
1606
|
+
portalId: "tooltip-portal",
|
|
1607
|
+
getTriggerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTriggerId(ctx)),
|
|
1608
|
+
getContentEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getContentId(ctx)),
|
|
1609
|
+
getPositionerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPositionerId(ctx)),
|
|
1610
|
+
getArrowEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getArrowId(ctx)),
|
|
1611
|
+
getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx)),
|
|
1612
|
+
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.portalId),
|
|
1613
|
+
createPortalEl: (ctx) => {
|
|
1614
|
+
const portal = dom.getDoc(ctx).createElement("tooltip-portal");
|
|
1615
|
+
portal.id = dom.portalId;
|
|
1616
|
+
return portal;
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
|
|
1620
|
+
// ../../../node_modules/@zag-js/core/src/index.ts
|
|
1621
|
+
var import_vanilla3 = require("valtio/vanilla");
|
|
1622
|
+
|
|
1623
|
+
// ../../core/src/action-utils.ts
|
|
1624
|
+
function isGuardHelper(value) {
|
|
1625
|
+
return isObject(value) && value.predicate != null;
|
|
1626
|
+
}
|
|
1627
|
+
function determineActionsFn(values, guardMap) {
|
|
1628
|
+
return (context, event) => {
|
|
1629
|
+
if (isGuardHelper(values))
|
|
1630
|
+
return values.predicate(guardMap != null ? guardMap : {})(context, event);
|
|
1631
|
+
return values;
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// ../../core/src/guard-utils.ts
|
|
1636
|
+
function isGuardHelper2(value) {
|
|
1637
|
+
return isObject(value) && value.predicate != null;
|
|
1638
|
+
}
|
|
1639
|
+
var TruthyGuard = () => true;
|
|
1640
|
+
function determineGuardFn(guard, guardMap) {
|
|
1641
|
+
guard = guard != null ? guard : TruthyGuard;
|
|
1642
|
+
return (context, event) => {
|
|
1643
|
+
if (isString(guard)) {
|
|
1644
|
+
const value = guardMap == null ? void 0 : guardMap[guard];
|
|
1645
|
+
return isFunction(value) ? value(context, event) : value;
|
|
1646
|
+
}
|
|
1647
|
+
if (isGuardHelper2(guard)) {
|
|
1648
|
+
return guard.predicate(guardMap != null ? guardMap : {})(context, event);
|
|
1649
|
+
}
|
|
1650
|
+
return guard == null ? void 0 : guard(context, event);
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
// ../../../node_modules/klona/json/index.mjs
|
|
1655
|
+
function klona(val) {
|
|
1656
|
+
var k, out, tmp;
|
|
1657
|
+
if (Array.isArray(val)) {
|
|
1658
|
+
out = Array(k = val.length);
|
|
1659
|
+
while (k--)
|
|
1660
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
1661
|
+
return out;
|
|
1662
|
+
}
|
|
1663
|
+
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
1664
|
+
out = {};
|
|
1665
|
+
for (k in val) {
|
|
1666
|
+
if (k === "__proto__") {
|
|
1667
|
+
Object.defineProperty(out, k, {
|
|
1668
|
+
value: klona(val[k]),
|
|
1669
|
+
configurable: true,
|
|
1670
|
+
enumerable: true,
|
|
1671
|
+
writable: true
|
|
1672
|
+
});
|
|
1673
|
+
} else {
|
|
1674
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
return out;
|
|
1678
|
+
}
|
|
1679
|
+
return val;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
// ../../core/src/machine.ts
|
|
1683
|
+
var import_utils13 = require("valtio/utils");
|
|
1684
|
+
var import_vanilla2 = require("valtio/vanilla");
|
|
1685
|
+
|
|
1686
|
+
// ../../core/src/create-proxy.ts
|
|
1687
|
+
var import_vanilla = require("valtio/vanilla");
|
|
1688
|
+
function createProxy(config) {
|
|
1689
|
+
var _a;
|
|
1690
|
+
const state = (0, import_vanilla.proxy)({
|
|
1691
|
+
value: "",
|
|
1692
|
+
previousValue: "",
|
|
1693
|
+
event: cast({}),
|
|
1694
|
+
context: (_a = config.context) != null ? _a : cast({}),
|
|
1695
|
+
done: false,
|
|
1696
|
+
tags: [],
|
|
1697
|
+
hasTag(tag) {
|
|
1698
|
+
return this.tags.includes(tag);
|
|
1699
|
+
},
|
|
1700
|
+
matches(...value) {
|
|
1701
|
+
return value.includes(this.value);
|
|
1702
|
+
},
|
|
1703
|
+
can(event) {
|
|
1704
|
+
return cast(this).nextEvents.includes(event);
|
|
1705
|
+
},
|
|
1706
|
+
get nextEvents() {
|
|
1707
|
+
var _a2, _b, _c, _d;
|
|
1708
|
+
const stateEvents = (_c = (_b = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b["on"]) != null ? _c : {};
|
|
1709
|
+
const globalEvents = (_d = config == null ? void 0 : config.on) != null ? _d : {};
|
|
1710
|
+
return Object.keys(__spreadValues(__spreadValues({}, stateEvents), globalEvents));
|
|
1711
|
+
},
|
|
1712
|
+
get changed() {
|
|
1713
|
+
if (this.event.value === "machine.init" /* Init */ || !this.previousValue)
|
|
1714
|
+
return false;
|
|
1715
|
+
return this.value !== this.previousValue;
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
return cast(state);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// ../../core/src/delay-utils.ts
|
|
1722
|
+
function determineDelayFn(delay, delaysMap) {
|
|
1723
|
+
return (context, event) => {
|
|
1724
|
+
if (isNumber(delay))
|
|
1725
|
+
return delay;
|
|
1726
|
+
if (isFunction(delay)) {
|
|
1727
|
+
return delay(context, event);
|
|
1728
|
+
}
|
|
1729
|
+
if (isString(delay)) {
|
|
1730
|
+
const value = Number.parseFloat(delay);
|
|
1731
|
+
if (!Number.isNaN(value)) {
|
|
1732
|
+
return value;
|
|
1733
|
+
}
|
|
1734
|
+
if (delaysMap) {
|
|
1735
|
+
const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay];
|
|
1736
|
+
if (valueOrFn == null) {
|
|
1737
|
+
const msg = `[machine] Cannot determine delay for ${delay}. It doesn't exist in options.delays`;
|
|
1738
|
+
throw new Error(msg);
|
|
1739
|
+
}
|
|
1740
|
+
return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
// ../../core/src/utils.ts
|
|
1747
|
+
function toEvent(event) {
|
|
1748
|
+
const obj = isString(event) ? { type: event } : event;
|
|
1749
|
+
return obj;
|
|
1750
|
+
}
|
|
1751
|
+
function toArray(value) {
|
|
1752
|
+
if (!value)
|
|
1753
|
+
return [];
|
|
1754
|
+
return isArray(value) ? value : [value];
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
// ../../core/src/transition-utils.ts
|
|
1758
|
+
function toTarget(target) {
|
|
1759
|
+
return isString(target) ? { target } : target;
|
|
1760
|
+
}
|
|
1761
|
+
function determineTransitionFn(transitions, guardMap) {
|
|
1762
|
+
return (context, event) => {
|
|
1763
|
+
return toArray(transitions).map(toTarget).find((transition) => {
|
|
1764
|
+
var _a;
|
|
1765
|
+
const determineGuard = determineGuardFn(transition.guard, guardMap);
|
|
1766
|
+
const guard = determineGuard(context, event);
|
|
1767
|
+
return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
|
|
1768
|
+
});
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
function toTransition(transition, current) {
|
|
1772
|
+
const _transition = isString(transition) ? toTarget(transition) : transition;
|
|
1773
|
+
const fn = (t2) => {
|
|
1774
|
+
const isTargetless = t2.actions && !t2.target;
|
|
1775
|
+
if (isTargetless && current)
|
|
1776
|
+
t2.target = current;
|
|
1777
|
+
return t2;
|
|
1778
|
+
};
|
|
1779
|
+
if (isArray(_transition)) {
|
|
1780
|
+
return _transition.map(fn);
|
|
1781
|
+
}
|
|
1782
|
+
if (isObject(_transition)) {
|
|
1783
|
+
return fn(cast(_transition));
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// ../../core/src/machine.ts
|
|
1788
|
+
var Machine = class {
|
|
1789
|
+
constructor(config, options) {
|
|
1790
|
+
this.config = config;
|
|
1791
|
+
this.status = "Not Started" /* NotStarted */;
|
|
1792
|
+
this.type = "machine" /* Machine */;
|
|
1793
|
+
this.activityEvents = /* @__PURE__ */ new Map();
|
|
1794
|
+
this.delayedEvents = /* @__PURE__ */ new Map();
|
|
1795
|
+
this.stateListeners = /* @__PURE__ */ new Set();
|
|
1796
|
+
this.eventListeners = /* @__PURE__ */ new Set();
|
|
1797
|
+
this.doneListeners = /* @__PURE__ */ new Set();
|
|
1798
|
+
this.contextWatchers = /* @__PURE__ */ new Set();
|
|
1799
|
+
this.removeStateListener = noop;
|
|
1800
|
+
this.removeEventListener = noop;
|
|
1801
|
+
this.children = /* @__PURE__ */ new Map();
|
|
1802
|
+
this.start = (init) => {
|
|
1803
|
+
if (this.status === "Running" /* Running */) {
|
|
1804
|
+
return this;
|
|
1805
|
+
}
|
|
1806
|
+
this.status = "Running" /* Running */;
|
|
1807
|
+
const event = toEvent("machine.init" /* Init */);
|
|
1808
|
+
if (init) {
|
|
1809
|
+
const resolved = isObject(init) ? init : { context: this.config.context, value: init };
|
|
1810
|
+
this.setState(resolved.value);
|
|
1811
|
+
this.setContext(resolved.context);
|
|
1812
|
+
}
|
|
1813
|
+
const transition = {
|
|
1814
|
+
target: !!init ? void 0 : this.config.initial
|
|
1815
|
+
};
|
|
1816
|
+
const info = this.getNextStateInfo(transition, event);
|
|
1817
|
+
info.target = cast(info.target || transition.target);
|
|
1818
|
+
this.initialState = info;
|
|
1819
|
+
this.performStateChangeEffects(info.target, info, event);
|
|
1820
|
+
this.removeStateListener = (0, import_vanilla2.subscribe)(this.state, () => {
|
|
1821
|
+
this.stateListeners.forEach((listener) => {
|
|
1822
|
+
listener(this.stateSnapshot);
|
|
1823
|
+
});
|
|
1824
|
+
}, this.sync);
|
|
1825
|
+
this.removeEventListener = (0, import_utils13.subscribeKey)(this.state, "event", (value) => {
|
|
1826
|
+
if (this.config.onEvent) {
|
|
1827
|
+
this.executeActions(this.config.onEvent, value);
|
|
1828
|
+
}
|
|
1829
|
+
for (const listener of this.eventListeners) {
|
|
1830
|
+
listener(value);
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
this.setupContextWatchers();
|
|
1834
|
+
this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
|
|
1835
|
+
this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
|
|
1836
|
+
return this;
|
|
1837
|
+
};
|
|
1838
|
+
this.setupContextWatchers = () => {
|
|
1839
|
+
var _a;
|
|
1840
|
+
for (const [key, fn] of Object.entries((_a = this.config.watch) != null ? _a : {})) {
|
|
1841
|
+
this.contextWatchers.add((0, import_utils13.subscribeKey)(this.state.context, key, () => {
|
|
1842
|
+
this.executeActions(fn, this.state.event);
|
|
1843
|
+
}));
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1846
|
+
this.setupComputed = () => {
|
|
1847
|
+
var _a;
|
|
1848
|
+
const computed = cast((_a = this.config.computed) != null ? _a : {});
|
|
1849
|
+
const deriveFns = Object.fromEntries(Object.entries(computed).map(([key, fn]) => [key, (get) => fn(get(this.state.context))]));
|
|
1850
|
+
(0, import_utils13.derive)(deriveFns, { proxy: this.state.context });
|
|
1851
|
+
};
|
|
1852
|
+
this.detachComputed = () => {
|
|
1853
|
+
(0, import_utils13.underive)(this.state.context, { delete: true });
|
|
1854
|
+
};
|
|
1855
|
+
this.stop = () => {
|
|
1856
|
+
if (this.status === "Stopped" /* Stopped */)
|
|
1857
|
+
return;
|
|
1858
|
+
this.setState(null);
|
|
1859
|
+
this.setEvent("machine.stop" /* Stop */);
|
|
1860
|
+
if (this.config.context) {
|
|
1861
|
+
this.setContext(this.config.context);
|
|
1862
|
+
}
|
|
1863
|
+
this.stopStateListeners();
|
|
1864
|
+
this.stopChildren();
|
|
1865
|
+
this.stopActivities();
|
|
1866
|
+
this.stopDelayedEvents();
|
|
1867
|
+
this.stopContextWatchers();
|
|
1868
|
+
this.stopEventListeners();
|
|
1869
|
+
this.detachComputed();
|
|
1870
|
+
this.status = "Stopped" /* Stopped */;
|
|
1871
|
+
this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
|
|
1872
|
+
return this;
|
|
1873
|
+
};
|
|
1874
|
+
this.stopEventListeners = () => {
|
|
1875
|
+
this.eventListeners.clear();
|
|
1876
|
+
this.removeEventListener();
|
|
1877
|
+
};
|
|
1878
|
+
this.stopStateListeners = () => {
|
|
1879
|
+
this.removeStateListener();
|
|
1880
|
+
this.stateListeners.clear();
|
|
1881
|
+
};
|
|
1882
|
+
this.stopContextWatchers = () => {
|
|
1883
|
+
this.contextWatchers.forEach((fn) => fn());
|
|
1884
|
+
this.contextWatchers.clear();
|
|
1885
|
+
};
|
|
1886
|
+
this.stopDelayedEvents = () => {
|
|
1887
|
+
this.delayedEvents.forEach((state) => {
|
|
1888
|
+
state.forEach((stop) => stop());
|
|
1889
|
+
});
|
|
1890
|
+
this.delayedEvents.clear();
|
|
1891
|
+
};
|
|
1892
|
+
this.stopActivities = (state) => {
|
|
1893
|
+
var _a, _b;
|
|
1894
|
+
if (state) {
|
|
1895
|
+
(_a = this.activityEvents.get(state)) == null ? void 0 : _a.forEach((stop) => stop());
|
|
1896
|
+
(_b = this.activityEvents.get(state)) == null ? void 0 : _b.clear();
|
|
1897
|
+
this.activityEvents.delete(state);
|
|
1898
|
+
} else {
|
|
1899
|
+
this.activityEvents.forEach((state2) => {
|
|
1900
|
+
state2.forEach((stop) => stop());
|
|
1901
|
+
state2.clear();
|
|
1902
|
+
});
|
|
1903
|
+
this.activityEvents.clear();
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
this.sendChild = (evt, to) => {
|
|
1907
|
+
const event = toEvent(evt);
|
|
1908
|
+
const id = runIfFn(to, this.contextSnapshot);
|
|
1909
|
+
const child = this.children.get(id);
|
|
1910
|
+
if (!child) {
|
|
1911
|
+
invariant(`[machine/send-child] Cannot send '${event.type}' event to unknown child`);
|
|
1912
|
+
}
|
|
1913
|
+
child.send(event);
|
|
1914
|
+
};
|
|
1915
|
+
this.stopChild = (id) => {
|
|
1916
|
+
if (!this.children.has(id)) {
|
|
1917
|
+
invariant("[machine/stop-child] Cannot stop unknown child");
|
|
1918
|
+
}
|
|
1919
|
+
this.children.get(id).stop();
|
|
1920
|
+
this.children.delete(id);
|
|
1921
|
+
};
|
|
1922
|
+
this.removeChild = (id) => {
|
|
1923
|
+
this.children.delete(id);
|
|
1924
|
+
};
|
|
1925
|
+
this.stopChildren = () => {
|
|
1926
|
+
this.children.forEach((child) => child.stop());
|
|
1927
|
+
this.children.clear();
|
|
1928
|
+
};
|
|
1929
|
+
this.setParent = (parent) => {
|
|
1930
|
+
this.parent = parent;
|
|
1931
|
+
};
|
|
1932
|
+
this.spawn = (src, id) => {
|
|
1933
|
+
const actor = runIfFn(src);
|
|
1934
|
+
if (id)
|
|
1935
|
+
actor.id = id;
|
|
1936
|
+
actor.type = "machine.actor" /* Actor */;
|
|
1937
|
+
actor.setParent(this);
|
|
1938
|
+
this.children.set(actor.id, cast(actor));
|
|
1939
|
+
actor.onDone(() => {
|
|
1940
|
+
this.removeChild(actor.id);
|
|
1941
|
+
}).start();
|
|
1942
|
+
return cast((0, import_vanilla2.ref)(actor));
|
|
1943
|
+
};
|
|
1944
|
+
this.addActivityCleanup = (state, cleanup) => {
|
|
1945
|
+
var _a;
|
|
1946
|
+
if (!state)
|
|
1947
|
+
return;
|
|
1948
|
+
if (!this.activityEvents.has(state)) {
|
|
1949
|
+
this.activityEvents.set(state, /* @__PURE__ */ new Set([cleanup]));
|
|
1950
|
+
} else {
|
|
1951
|
+
(_a = this.activityEvents.get(state)) == null ? void 0 : _a.add(cleanup);
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
this.setState = (target) => {
|
|
1955
|
+
this.state.previousValue = this.state.value;
|
|
1956
|
+
this.state.value = target;
|
|
1957
|
+
const stateNode = this.getStateNode(target);
|
|
1958
|
+
if (target == null) {
|
|
1959
|
+
clear(this.state.tags);
|
|
1960
|
+
} else {
|
|
1961
|
+
this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
this.setContext = (context) => {
|
|
1965
|
+
for (const key in context) {
|
|
1966
|
+
this.state.context[key] = context[key];
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
this.withContext = (context) => {
|
|
1970
|
+
this.detachComputed();
|
|
1971
|
+
const newContext = __spreadValues(__spreadValues({}, this.config.context), context);
|
|
1972
|
+
return new Machine(__spreadProps(__spreadValues({}, this.config), { context: newContext }), this.options);
|
|
1973
|
+
};
|
|
1974
|
+
this.withOptions = (options) => {
|
|
1975
|
+
this.detachComputed();
|
|
1976
|
+
return new Machine(this.config, __spreadValues(__spreadValues({}, this.options), options));
|
|
1977
|
+
};
|
|
1978
|
+
this.setActions = (actions) => {
|
|
1979
|
+
this.actionMap = __spreadValues(__spreadValues({}, this.actionMap), actions);
|
|
1980
|
+
};
|
|
1981
|
+
this.clone = () => {
|
|
1982
|
+
this.detachComputed();
|
|
1983
|
+
return new Machine(this.config, this.options);
|
|
1984
|
+
};
|
|
1985
|
+
this.getStateNode = (state) => {
|
|
1986
|
+
var _a;
|
|
1987
|
+
if (!state)
|
|
1988
|
+
return;
|
|
1989
|
+
return (_a = this.config.states) == null ? void 0 : _a[state];
|
|
1990
|
+
};
|
|
1991
|
+
this.getNextStateInfo = (transitions, event) => {
|
|
1992
|
+
var _a;
|
|
1993
|
+
const transition = this.determineTransition(transitions, event);
|
|
1994
|
+
const target = (_a = transition == null ? void 0 : transition.target) != null ? _a : this.state.value;
|
|
1995
|
+
const stateNode = this.getStateNode(target);
|
|
1996
|
+
return {
|
|
1997
|
+
transition,
|
|
1998
|
+
stateNode,
|
|
1999
|
+
target
|
|
2000
|
+
};
|
|
2001
|
+
};
|
|
2002
|
+
this.getActionFromDelayedTransition = (transition) => {
|
|
2003
|
+
const event = toEvent("machine.after" /* After */);
|
|
2004
|
+
const determineDelay = determineDelayFn(transition.delay, this.delayMap);
|
|
2005
|
+
const delay = determineDelay(this.contextSnapshot, event);
|
|
2006
|
+
let id;
|
|
2007
|
+
return {
|
|
2008
|
+
entry: () => {
|
|
2009
|
+
id = globalThis.setTimeout(() => {
|
|
2010
|
+
const current = this.state.value;
|
|
2011
|
+
const next = this.getNextStateInfo(transition, event);
|
|
2012
|
+
this.performStateChangeEffects(current, next, event);
|
|
2013
|
+
}, delay);
|
|
2014
|
+
},
|
|
2015
|
+
exit: () => {
|
|
2016
|
+
globalThis.clearTimeout(id);
|
|
2017
|
+
}
|
|
2018
|
+
};
|
|
2019
|
+
};
|
|
2020
|
+
this.getDelayedEventActions = (state) => {
|
|
2021
|
+
const stateNode = this.getStateNode(state);
|
|
2022
|
+
const event = toEvent("machine.after" /* After */);
|
|
2023
|
+
if (!stateNode || !stateNode.after)
|
|
2024
|
+
return;
|
|
2025
|
+
const entries = [];
|
|
2026
|
+
const exits = [];
|
|
2027
|
+
if (isArray(stateNode.after)) {
|
|
2028
|
+
const transition = this.determineTransition(stateNode.after, event);
|
|
2029
|
+
if (!transition)
|
|
2030
|
+
return;
|
|
2031
|
+
const actions = this.getActionFromDelayedTransition(transition);
|
|
2032
|
+
entries.push(actions.entry);
|
|
2033
|
+
exits.push(actions.exit);
|
|
2034
|
+
} else if (isObject(stateNode.after)) {
|
|
2035
|
+
for (const delay in stateNode.after) {
|
|
2036
|
+
const transition = stateNode.after[delay];
|
|
2037
|
+
let resolvedTransition = {};
|
|
2038
|
+
if (isArray(transition)) {
|
|
2039
|
+
const picked = this.determineTransition(transition, event);
|
|
2040
|
+
if (picked)
|
|
2041
|
+
resolvedTransition = picked;
|
|
2042
|
+
} else if (isString(transition)) {
|
|
2043
|
+
resolvedTransition = { target: transition, delay };
|
|
2044
|
+
} else {
|
|
2045
|
+
resolvedTransition = __spreadProps(__spreadValues({}, transition), { delay });
|
|
2046
|
+
}
|
|
2047
|
+
const actions = this.getActionFromDelayedTransition(resolvedTransition);
|
|
2048
|
+
entries.push(actions.entry);
|
|
2049
|
+
exits.push(actions.exit);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
return { entries, exits };
|
|
2053
|
+
};
|
|
2054
|
+
this.executeActions = (actions, event) => {
|
|
2055
|
+
var _a;
|
|
2056
|
+
const _actions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event);
|
|
2057
|
+
for (const action of toArray(_actions)) {
|
|
2058
|
+
const fn = isString(action) ? (_a = this.actionMap) == null ? void 0 : _a[action] : action;
|
|
2059
|
+
warn(isString(action) && !fn, `[machine/exec-action] No implementation found for action: \`${action}\``);
|
|
2060
|
+
fn == null ? void 0 : fn(this.state.context, event, this.meta);
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
this.executeActivities = (event, activities, state) => {
|
|
2064
|
+
var _a;
|
|
2065
|
+
for (const activity of activities) {
|
|
2066
|
+
const fn = isString(activity) ? (_a = this.activityMap) == null ? void 0 : _a[activity] : activity;
|
|
2067
|
+
if (!fn) {
|
|
2068
|
+
warn(`[machine/exec-activity] No implementation found for activity: \`${activity}\``);
|
|
2069
|
+
continue;
|
|
2070
|
+
}
|
|
2071
|
+
const cleanup = fn(this.state.context, event, this.meta);
|
|
2072
|
+
if (cleanup) {
|
|
2073
|
+
this.addActivityCleanup(state != null ? state : this.state.value, cleanup);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
this.createEveryActivities = (every, callbackfn) => {
|
|
2078
|
+
if (!every)
|
|
2079
|
+
return;
|
|
2080
|
+
const event = toEvent("machine.every" /* Every */);
|
|
2081
|
+
if (isArray(every)) {
|
|
2082
|
+
const picked = toArray(every).find((t2) => {
|
|
2083
|
+
const determineDelay2 = determineDelayFn(t2.delay, this.delayMap);
|
|
2084
|
+
t2.delay = determineDelay2(this.contextSnapshot, event);
|
|
2085
|
+
const determineGuard = determineGuardFn(t2.guard, this.guardMap);
|
|
2086
|
+
const guard = determineGuard(this.contextSnapshot, event);
|
|
2087
|
+
return guard != null ? guard : t2.delay;
|
|
2088
|
+
});
|
|
2089
|
+
if (!picked)
|
|
2090
|
+
return;
|
|
2091
|
+
const determineDelay = determineDelayFn(picked.delay, this.delayMap);
|
|
2092
|
+
const delay = determineDelay(this.contextSnapshot, event);
|
|
2093
|
+
const activity = () => {
|
|
2094
|
+
const id = globalThis.setInterval(() => {
|
|
2095
|
+
this.executeActions(picked.actions, event);
|
|
2096
|
+
}, delay);
|
|
2097
|
+
return () => {
|
|
2098
|
+
globalThis.clearInterval(id);
|
|
2099
|
+
};
|
|
2100
|
+
};
|
|
2101
|
+
callbackfn(activity);
|
|
2102
|
+
} else {
|
|
2103
|
+
for (const interval in every) {
|
|
2104
|
+
const actions = every == null ? void 0 : every[interval];
|
|
2105
|
+
const determineDelay = determineDelayFn(interval, this.delayMap);
|
|
2106
|
+
const delay = determineDelay(this.contextSnapshot, event);
|
|
2107
|
+
const activity = () => {
|
|
2108
|
+
const id = globalThis.setInterval(() => {
|
|
2109
|
+
this.executeActions(actions, event);
|
|
2110
|
+
}, delay);
|
|
2111
|
+
return () => {
|
|
2112
|
+
globalThis.clearInterval(id);
|
|
2113
|
+
};
|
|
2114
|
+
};
|
|
2115
|
+
callbackfn(activity);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
this.setEvent = (event) => {
|
|
2120
|
+
this.state.event = (0, import_vanilla2.ref)(toEvent(event));
|
|
2121
|
+
};
|
|
2122
|
+
this.performExitEffects = (current, event) => {
|
|
2123
|
+
const currentState = this.state.value;
|
|
2124
|
+
const stateNode = current ? this.getStateNode(current) : void 0;
|
|
2125
|
+
this.stopActivities(currentState);
|
|
2126
|
+
const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event);
|
|
2127
|
+
const exitActions = toArray(_exit);
|
|
2128
|
+
const afterExitActions = this.delayedEvents.get(currentState);
|
|
2129
|
+
if (afterExitActions) {
|
|
2130
|
+
exitActions.push(...afterExitActions);
|
|
2131
|
+
}
|
|
2132
|
+
this.executeActions(exitActions, event);
|
|
2133
|
+
this.eventListeners.clear();
|
|
2134
|
+
};
|
|
2135
|
+
this.performEntryEffects = (next, event) => {
|
|
2136
|
+
const stateNode = this.getStateNode(next);
|
|
2137
|
+
const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
|
|
2138
|
+
this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
|
|
2139
|
+
activities.unshift(activity);
|
|
2140
|
+
});
|
|
2141
|
+
if (activities.length > 0) {
|
|
2142
|
+
this.executeActivities(event, activities);
|
|
2143
|
+
}
|
|
2144
|
+
const _entry = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(this.contextSnapshot, event);
|
|
2145
|
+
const entryActions = toArray(_entry);
|
|
2146
|
+
const afterActions = this.getDelayedEventActions(next);
|
|
2147
|
+
if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
|
|
2148
|
+
this.delayedEvents.set(next, afterActions == null ? void 0 : afterActions.exits);
|
|
2149
|
+
entryActions.push(...afterActions.entries);
|
|
2150
|
+
}
|
|
2151
|
+
this.executeActions(entryActions, event);
|
|
2152
|
+
if ((stateNode == null ? void 0 : stateNode.type) === "final") {
|
|
2153
|
+
this.state.done = true;
|
|
2154
|
+
this.doneListeners.forEach((listener) => {
|
|
2155
|
+
listener(this.stateSnapshot);
|
|
2156
|
+
});
|
|
2157
|
+
this.stop();
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
this.performTransitionEffects = (transition, event) => {
|
|
2161
|
+
const t2 = this.determineTransition(transition, event);
|
|
2162
|
+
this.executeActions(t2 == null ? void 0 : t2.actions, event);
|
|
2163
|
+
};
|
|
2164
|
+
this.performStateChangeEffects = (current, next, event) => {
|
|
2165
|
+
var _a, _b;
|
|
2166
|
+
this.setEvent(event);
|
|
2167
|
+
next.target = (_b = (_a = next.target) != null ? _a : this.state.value) != null ? _b : void 0;
|
|
2168
|
+
const ok = next.target && next.target !== this.state.value;
|
|
2169
|
+
if (ok) {
|
|
2170
|
+
this.performExitEffects(current, event);
|
|
2171
|
+
}
|
|
2172
|
+
this.performTransitionEffects(next == null ? void 0 : next.transition, event);
|
|
2173
|
+
this.setState(next.target);
|
|
2174
|
+
if (ok) {
|
|
2175
|
+
this.performEntryEffects(next.target, event);
|
|
2176
|
+
}
|
|
2177
|
+
};
|
|
2178
|
+
this.determineTransition = (transition, event) => {
|
|
2179
|
+
const fn = determineTransitionFn(transition, this.guardMap);
|
|
2180
|
+
return fn == null ? void 0 : fn(this.contextSnapshot, event);
|
|
2181
|
+
};
|
|
2182
|
+
this.sendParent = (evt) => {
|
|
2183
|
+
var _a;
|
|
2184
|
+
if (!this.parent) {
|
|
2185
|
+
invariant("[machine/send-parent] Cannot send event to an unknown parent");
|
|
2186
|
+
}
|
|
2187
|
+
const event = toEvent(evt);
|
|
2188
|
+
(_a = this.parent) == null ? void 0 : _a.send(event);
|
|
2189
|
+
};
|
|
2190
|
+
this.send = (evt) => {
|
|
2191
|
+
const event = toEvent(evt);
|
|
2192
|
+
this.transition(this.state.value, event);
|
|
2193
|
+
};
|
|
2194
|
+
this.transition = (state, evt) => {
|
|
2195
|
+
var _a, _b, _c;
|
|
2196
|
+
const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
|
|
2197
|
+
const event = toEvent(evt);
|
|
2198
|
+
if (!stateNode && !this.config.on) {
|
|
2199
|
+
const msg = this.status === "Stopped" /* Stopped */ ? "[machine/transition] Cannot transition a stopped machine" : "[machine/transition] State does not have a definition";
|
|
2200
|
+
warn(msg);
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
const transitionConfig = (_c = (_a = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a[event.type]) != null ? _c : (_b = this.config.on) == null ? void 0 : _b[event.type];
|
|
2204
|
+
const transition = toTransition(transitionConfig, this.state.value);
|
|
2205
|
+
if (!transition)
|
|
2206
|
+
return;
|
|
2207
|
+
const info = this.getNextStateInfo(transition, event);
|
|
2208
|
+
this.performStateChangeEffects(this.state.value, info, event);
|
|
2209
|
+
return info.stateNode;
|
|
2210
|
+
};
|
|
2211
|
+
this.subscribe = (listener) => {
|
|
2212
|
+
this.stateListeners.add(listener);
|
|
2213
|
+
if (this.status === "Running" /* Running */) {
|
|
2214
|
+
listener(this.stateSnapshot);
|
|
2215
|
+
}
|
|
2216
|
+
return () => {
|
|
2217
|
+
this.stateListeners.delete(listener);
|
|
2218
|
+
};
|
|
2219
|
+
};
|
|
2220
|
+
this.onDone = (listener) => {
|
|
2221
|
+
this.doneListeners.add(listener);
|
|
2222
|
+
return this;
|
|
2223
|
+
};
|
|
2224
|
+
this.onTransition = (listener) => {
|
|
2225
|
+
this.stateListeners.add(listener);
|
|
2226
|
+
if (this.status === "Running" /* Running */) {
|
|
2227
|
+
listener(this.stateSnapshot);
|
|
2228
|
+
}
|
|
2229
|
+
return this;
|
|
2230
|
+
};
|
|
2231
|
+
this.onEvent = (listener) => {
|
|
2232
|
+
listener(this.state.event);
|
|
2233
|
+
this.eventListeners.add(listener);
|
|
2234
|
+
return this;
|
|
2235
|
+
};
|
|
2236
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2237
|
+
this.options = klona(options);
|
|
2238
|
+
this.id = (_a = config.id) != null ? _a : `machine-${uuid()}`;
|
|
2239
|
+
this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
|
|
2240
|
+
this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
|
|
2241
|
+
this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
|
|
2242
|
+
this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
|
|
2243
|
+
this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
|
|
2244
|
+
this.state = createProxy(klona(config));
|
|
2245
|
+
this.setupComputed();
|
|
2246
|
+
const event = toEvent("machine.created" /* Created */);
|
|
2247
|
+
this.executeActions(config == null ? void 0 : config.created, event);
|
|
2248
|
+
}
|
|
2249
|
+
get stateSnapshot() {
|
|
2250
|
+
return cast((0, import_vanilla2.snapshot)(this.state));
|
|
2251
|
+
}
|
|
2252
|
+
get contextSnapshot() {
|
|
2253
|
+
return this.stateSnapshot.context;
|
|
2254
|
+
}
|
|
2255
|
+
get self() {
|
|
2256
|
+
const _self = this;
|
|
2257
|
+
return {
|
|
2258
|
+
id: this.id,
|
|
2259
|
+
send: this.send.bind(this),
|
|
2260
|
+
sendParent: this.sendParent.bind(this),
|
|
2261
|
+
sendChild: this.sendChild.bind(this),
|
|
2262
|
+
stop: this.stop.bind(this),
|
|
2263
|
+
stopChild: this.stopChild.bind(this),
|
|
2264
|
+
spawn: this.spawn.bind(this),
|
|
2265
|
+
get state() {
|
|
2266
|
+
return _self.stateSnapshot;
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
get meta() {
|
|
2271
|
+
return {
|
|
2272
|
+
state: this.stateSnapshot,
|
|
2273
|
+
guards: this.guardMap,
|
|
2274
|
+
send: this.send.bind(this),
|
|
2275
|
+
listen: this.onEvent.bind(this),
|
|
2276
|
+
self: this.self,
|
|
2277
|
+
getState: () => this.stateSnapshot
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
var createMachine = (config, options) => new Machine(config, options);
|
|
2282
|
+
|
|
2283
|
+
// src/tooltip.store.ts
|
|
2284
|
+
var store = (0, import_vanilla3.proxy)({
|
|
2285
|
+
id: null,
|
|
2286
|
+
prevId: null,
|
|
2287
|
+
setId(val) {
|
|
2288
|
+
this.prevId = this.id;
|
|
2289
|
+
this.id = val;
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
|
|
2293
|
+
// src/tooltip.connect.ts
|
|
2294
|
+
function connect(state, send, normalize = normalizeProp) {
|
|
2295
|
+
const id = state.context.id;
|
|
2296
|
+
const hasAriaLabel = state.context.hasAriaLabel;
|
|
2297
|
+
const isOpen = state.hasTag("open");
|
|
2298
|
+
const triggerId = dom.getTriggerId(state.context);
|
|
2299
|
+
const contentId = dom.getContentId(state.context);
|
|
2300
|
+
const popperStyles = getPlacementStyles({
|
|
2301
|
+
measured: !!state.context.isPlacementComplete
|
|
2302
|
+
});
|
|
2303
|
+
return {
|
|
2304
|
+
isOpen,
|
|
2305
|
+
open() {
|
|
2306
|
+
send("OPEN");
|
|
2307
|
+
},
|
|
2308
|
+
close() {
|
|
2309
|
+
send("CLOSE");
|
|
2310
|
+
},
|
|
2311
|
+
getAnimationState() {
|
|
2312
|
+
return {
|
|
2313
|
+
enter: store.prevId === null && id === store.id,
|
|
2314
|
+
exit: store.id === null
|
|
2315
|
+
};
|
|
2316
|
+
},
|
|
2317
|
+
triggerProps: normalize.button({
|
|
2318
|
+
"data-part": "trigger",
|
|
2319
|
+
id: triggerId,
|
|
2320
|
+
"data-expanded": dataAttr(isOpen),
|
|
2321
|
+
"aria-describedby": isOpen ? contentId : void 0,
|
|
2322
|
+
onClick() {
|
|
2323
|
+
send("CLICK");
|
|
2324
|
+
},
|
|
2325
|
+
onFocus() {
|
|
2326
|
+
send("FOCUS");
|
|
2327
|
+
},
|
|
2328
|
+
onBlur() {
|
|
2329
|
+
if (id === store.id) {
|
|
2330
|
+
send("BLUR");
|
|
2331
|
+
}
|
|
2332
|
+
},
|
|
2333
|
+
onPointerDown() {
|
|
2334
|
+
if (id === store.id) {
|
|
2335
|
+
send("POINTER_DOWN");
|
|
2336
|
+
}
|
|
2337
|
+
},
|
|
2338
|
+
onPointerMove() {
|
|
2339
|
+
send("POINTER_ENTER");
|
|
2340
|
+
},
|
|
2341
|
+
onPointerLeave() {
|
|
2342
|
+
send("POINTER_LEAVE");
|
|
2343
|
+
},
|
|
2344
|
+
onPointerCancel() {
|
|
2345
|
+
send("POINTER_LEAVE");
|
|
2346
|
+
}
|
|
2347
|
+
}),
|
|
2348
|
+
arrowProps: normalize.element({
|
|
2349
|
+
id: dom.getArrowId(state.context),
|
|
2350
|
+
"data-part": "arrow",
|
|
2351
|
+
style: popperStyles.arrow
|
|
2352
|
+
}),
|
|
2353
|
+
innerArrowProps: normalize.element({
|
|
2354
|
+
"data-part": "arrow-inner",
|
|
2355
|
+
style: popperStyles.innerArrow
|
|
2356
|
+
}),
|
|
2357
|
+
positionerProps: normalize.element({
|
|
2358
|
+
id: dom.getPositionerId(state.context),
|
|
2359
|
+
"data-part": "positioner",
|
|
2360
|
+
style: popperStyles.floating
|
|
2361
|
+
}),
|
|
2362
|
+
contentProps: normalize.element({
|
|
2363
|
+
"data-part": "content",
|
|
2364
|
+
role: hasAriaLabel ? void 0 : "tooltip",
|
|
2365
|
+
id: hasAriaLabel ? void 0 : contentId,
|
|
2366
|
+
"data-placement": state.context.currentPlacement,
|
|
2367
|
+
onPointerEnter() {
|
|
2368
|
+
send("TOOLTIP_POINTER_ENTER");
|
|
2369
|
+
},
|
|
2370
|
+
onPointerLeave() {
|
|
2371
|
+
send("TOOLTIP_POINTER_LEAVE");
|
|
2372
|
+
},
|
|
2373
|
+
style: {
|
|
2374
|
+
pointerEvents: state.context.interactive ? "auto" : "none"
|
|
2375
|
+
}
|
|
2376
|
+
}),
|
|
2377
|
+
labelProps: normalize.element({
|
|
2378
|
+
"data-part": "label",
|
|
2379
|
+
id: contentId,
|
|
2380
|
+
role: "tooltip",
|
|
2381
|
+
style: visuallyHiddenStyle,
|
|
2382
|
+
children: state.context["aria-label"]
|
|
2383
|
+
}),
|
|
2384
|
+
createPortal() {
|
|
2385
|
+
const doc = dom.getDoc(state.context);
|
|
2386
|
+
const exist = dom.getPortalEl(state.context);
|
|
2387
|
+
if (exist)
|
|
2388
|
+
return exist;
|
|
2389
|
+
const portal = dom.createPortalEl(state.context);
|
|
2390
|
+
doc.body.appendChild(portal);
|
|
2391
|
+
return portal;
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
// src/tooltip.machine.ts
|
|
2397
|
+
var machine = createMachine({
|
|
2398
|
+
id: "tooltip",
|
|
2399
|
+
initial: "unknown",
|
|
2400
|
+
context: {
|
|
2401
|
+
id: "",
|
|
2402
|
+
openDelay: 1e3,
|
|
2403
|
+
closeDelay: 500,
|
|
2404
|
+
closeOnPointerDown: true,
|
|
2405
|
+
closeOnEsc: true,
|
|
2406
|
+
interactive: true,
|
|
2407
|
+
positioning: { placement: "bottom" },
|
|
2408
|
+
currentPlacement: void 0
|
|
2409
|
+
},
|
|
2410
|
+
computed: {
|
|
2411
|
+
hasAriaLabel: (ctx) => !!ctx["aria-label"]
|
|
2412
|
+
},
|
|
2413
|
+
on: {
|
|
2414
|
+
OPEN: "open",
|
|
2415
|
+
CLOSE: "closed"
|
|
2416
|
+
},
|
|
2417
|
+
states: {
|
|
2418
|
+
unknown: {
|
|
2419
|
+
on: {
|
|
2420
|
+
SETUP: {
|
|
2421
|
+
target: "closed",
|
|
2422
|
+
actions: "setupDocument"
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
},
|
|
2426
|
+
closed: {
|
|
2427
|
+
tags: ["closed"],
|
|
2428
|
+
entry: ["clearGlobalId", "invokeOnClose"],
|
|
2429
|
+
on: {
|
|
2430
|
+
FOCUS: "open",
|
|
2431
|
+
POINTER_ENTER: [
|
|
2432
|
+
{
|
|
2433
|
+
guard: "noVisibleTooltip",
|
|
2434
|
+
target: "opening"
|
|
2435
|
+
},
|
|
2436
|
+
{ target: "open" }
|
|
2437
|
+
]
|
|
2438
|
+
}
|
|
2439
|
+
},
|
|
2440
|
+
opening: {
|
|
2441
|
+
tags: ["closed"],
|
|
2442
|
+
activities: ["trackScroll", "trackPointerlockChange"],
|
|
2443
|
+
after: {
|
|
2444
|
+
OPEN_DELAY: "open"
|
|
2445
|
+
},
|
|
2446
|
+
on: {
|
|
2447
|
+
POINTER_LEAVE: "closed",
|
|
2448
|
+
BLUR: "closed",
|
|
2449
|
+
SCROLL: "closed",
|
|
2450
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
2451
|
+
POINTER_DOWN: {
|
|
2452
|
+
guard: "closeOnPointerDown",
|
|
2453
|
+
target: "closed"
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
},
|
|
2457
|
+
open: {
|
|
2458
|
+
tags: ["open"],
|
|
2459
|
+
activities: [
|
|
2460
|
+
"trackEscapeKey",
|
|
2461
|
+
"trackDisabledTriggerOnSafari",
|
|
2462
|
+
"trackScroll",
|
|
2463
|
+
"trackPointerlockChange",
|
|
2464
|
+
"computePlacement"
|
|
2465
|
+
],
|
|
2466
|
+
entry: ["setGlobalId", "invokeOnOpen"],
|
|
2467
|
+
on: {
|
|
2468
|
+
POINTER_LEAVE: [
|
|
2469
|
+
{
|
|
2470
|
+
guard: "isVisible",
|
|
2471
|
+
target: "closing"
|
|
2472
|
+
},
|
|
2473
|
+
{ target: "closed" }
|
|
2474
|
+
],
|
|
2475
|
+
BLUR: "closed",
|
|
2476
|
+
ESCAPE: "closed",
|
|
2477
|
+
SCROLL: "closed",
|
|
2478
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
2479
|
+
TOOLTIP_POINTER_LEAVE: {
|
|
2480
|
+
guard: "isInteractive",
|
|
2481
|
+
target: "closing"
|
|
2482
|
+
},
|
|
2483
|
+
POINTER_DOWN: {
|
|
2484
|
+
guard: "closeOnPointerDown",
|
|
2485
|
+
target: "closed"
|
|
2486
|
+
},
|
|
2487
|
+
CLICK: "closed"
|
|
2488
|
+
}
|
|
2489
|
+
},
|
|
2490
|
+
closing: {
|
|
2491
|
+
tags: ["open"],
|
|
2492
|
+
activities: ["trackStore", "computePlacement"],
|
|
2493
|
+
after: {
|
|
2494
|
+
CLOSE_DELAY: "closed"
|
|
2495
|
+
},
|
|
2496
|
+
on: {
|
|
2497
|
+
FORCE_CLOSE: "closed",
|
|
2498
|
+
POINTER_ENTER: "open",
|
|
2499
|
+
TOOLTIP_POINTER_ENTER: {
|
|
2500
|
+
guard: "isInteractive",
|
|
2501
|
+
target: "open"
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
}, {
|
|
2507
|
+
activities: {
|
|
2508
|
+
computePlacement(ctx) {
|
|
2509
|
+
ctx.currentPlacement = ctx.positioning.placement;
|
|
2510
|
+
let cleanup;
|
|
2511
|
+
raf(() => {
|
|
2512
|
+
cleanup = getPlacement(dom.getTriggerEl(ctx), dom.getPositionerEl(ctx), __spreadProps(__spreadValues({}, ctx.positioning), {
|
|
2513
|
+
onComplete(data) {
|
|
2514
|
+
ctx.currentPlacement = data.placement;
|
|
2515
|
+
ctx.isPlacementComplete = true;
|
|
2516
|
+
},
|
|
2517
|
+
onCleanup() {
|
|
2518
|
+
ctx.currentPlacement = void 0;
|
|
2519
|
+
ctx.isPlacementComplete = false;
|
|
2520
|
+
}
|
|
2521
|
+
}));
|
|
2522
|
+
});
|
|
2523
|
+
return cleanup;
|
|
2524
|
+
},
|
|
2525
|
+
trackPointerlockChange(ctx, _evt, { send }) {
|
|
2526
|
+
return addPointerlockChangeListener(dom.getDoc(ctx), () => {
|
|
2527
|
+
send("POINTER_LOCK_CHANGE");
|
|
2528
|
+
});
|
|
2529
|
+
},
|
|
2530
|
+
trackScroll(ctx, _evt, { send }) {
|
|
2531
|
+
const trigger = dom.getTriggerEl(ctx);
|
|
2532
|
+
if (!trigger)
|
|
2533
|
+
return;
|
|
2534
|
+
const cleanups = getScrollParents(trigger).map((el) => {
|
|
2535
|
+
const opts = { passive: true, capture: true };
|
|
2536
|
+
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
2537
|
+
});
|
|
2538
|
+
return () => {
|
|
2539
|
+
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
2540
|
+
};
|
|
2541
|
+
},
|
|
2542
|
+
trackStore(ctx, _evt, { send }) {
|
|
2543
|
+
return (0, import_vanilla3.subscribe)(store, () => {
|
|
2544
|
+
if (store.id !== ctx.id) {
|
|
2545
|
+
send("FORCE_CLOSE");
|
|
2546
|
+
}
|
|
2547
|
+
});
|
|
2548
|
+
},
|
|
2549
|
+
trackDisabledTriggerOnSafari(ctx, _evt, { send }) {
|
|
2550
|
+
if (!isSafari())
|
|
2551
|
+
return noop;
|
|
2552
|
+
const doc = dom.getDoc(ctx);
|
|
2553
|
+
return addPointerEvent(doc, "pointermove", (event) => {
|
|
2554
|
+
const selector = "[data-part=trigger][data-expanded]";
|
|
2555
|
+
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
2556
|
+
return;
|
|
2557
|
+
send("POINTER_LEAVE");
|
|
2558
|
+
});
|
|
2559
|
+
},
|
|
2560
|
+
trackEscapeKey(ctx, _evt, { send }) {
|
|
2561
|
+
if (!ctx.closeOnEsc)
|
|
2562
|
+
return;
|
|
2563
|
+
const doc = dom.getDoc(ctx);
|
|
2564
|
+
return addDomEvent(doc, "keydown", (event) => {
|
|
2565
|
+
if (event.key === "Escape") {
|
|
2566
|
+
send("ESCAPE");
|
|
2567
|
+
}
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
},
|
|
2571
|
+
actions: {
|
|
2572
|
+
setupDocument(ctx, evt) {
|
|
2573
|
+
ctx.id = evt.id;
|
|
2574
|
+
if (evt.doc)
|
|
2575
|
+
ctx.doc = (0, import_vanilla3.ref)(evt.doc);
|
|
2576
|
+
},
|
|
2577
|
+
setGlobalId(ctx) {
|
|
2578
|
+
store.setId(ctx.id);
|
|
2579
|
+
},
|
|
2580
|
+
clearGlobalId(ctx) {
|
|
2581
|
+
if (ctx.id === store.id) {
|
|
2582
|
+
store.setId(null);
|
|
2583
|
+
}
|
|
2584
|
+
},
|
|
2585
|
+
invokeOnOpen(ctx, evt) {
|
|
2586
|
+
var _a;
|
|
2587
|
+
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
2588
|
+
if (!omit.includes(evt.type)) {
|
|
2589
|
+
(_a = ctx.onOpen) == null ? void 0 : _a.call(ctx);
|
|
2590
|
+
}
|
|
2591
|
+
},
|
|
2592
|
+
invokeOnClose(ctx, evt) {
|
|
2593
|
+
var _a;
|
|
2594
|
+
const omit = ["SETUP"];
|
|
2595
|
+
if (!omit.includes(evt.type)) {
|
|
2596
|
+
(_a = ctx.onClose) == null ? void 0 : _a.call(ctx);
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
},
|
|
2600
|
+
guards: {
|
|
2601
|
+
closeOnPointerDown: (ctx) => ctx.closeOnPointerDown,
|
|
2602
|
+
noVisibleTooltip: () => store.id === null,
|
|
2603
|
+
isVisible: (ctx) => ctx.id === store.id,
|
|
2604
|
+
isInteractive: (ctx) => ctx.interactive
|
|
2605
|
+
},
|
|
2606
|
+
delays: {
|
|
2607
|
+
OPEN_DELAY: (ctx) => ctx.openDelay,
|
|
2608
|
+
CLOSE_DELAY: (ctx) => ctx.closeDelay
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2
2611
|
//# sourceMappingURL=index.js.map
|