New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/popper

Package Overview
Dependencies
Maintainers
1
Versions
918
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/popper - npm Package Compare versions

Comparing version

to
0.0.0-dev-20220413174154

dist/auto-update.d.ts.map

1

dist/auto-update.d.ts

@@ -9,1 +9,2 @@ import type { Placement, ReferenceElement } from "@floating-ui/dom";

export declare function autoUpdate(reference: ReferenceElement, floating: HTMLElement, update: () => void, options?: boolean | AutoUpdateOptions): (v: void) => void;
//# sourceMappingURL=auto-update.d.ts.map
import type { VirtualElement } from "@floating-ui/dom";
import { PositioningOptions } from "./types";
export declare function getPlacement(reference: HTMLElement | VirtualElement | null, floating: HTMLElement | null, options?: PositioningOptions): (v: void) => void;
//# sourceMappingURL=get-placement.d.ts.map

@@ -34,1 +34,2 @@ declare type Options = {

export {};
//# sourceMappingURL=get-styles.d.ts.map
export { getPlacement } from "./get-placement";
export { getPlacementStyles } from "./get-styles";
export type { Placement, PositioningOptions } from "./types";
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,1394 @@

var et=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var $t=Object.prototype.hasOwnProperty;var Kt=(t,e)=>{for(var n in e)et(t,n,{get:e[n],enumerable:!0})},Yt=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of qt(e))!$t.call(t,r)&&r!==n&&et(t,r,{get:()=>e[r],enumerable:!(o=Ut(e,r))||o.enumerable});return t};var Xt=t=>Yt(et({},"__esModule",{value:!0}),t);var Se={};Kt(Se,{getPlacement:()=>Ft,getPlacementStyles:()=>Bt});module.exports=Xt(Se);function H(t){return t.split("-")[0]}function Y(t){return t.split("-")[1]}function B(t){return["top","bottom"].includes(H(t))?"x":"y"}function ot(t){return t==="y"?"height":"width"}function vt(t,e,n){let{reference:o,floating:r}=t,l=o.x+o.width/2-r.width/2,s=o.y+o.height/2-r.height/2,c=B(e),i=ot(c),u=o[i]/2-r[i]/2,d=H(e),a=c==="x",f;switch(d){case"top":f={x:l,y:o.y-r.height};break;case"bottom":f={x:l,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:s};break;case"left":f={x:o.x-r.width,y:s};break;default:f={x:o.x,y:o.y}}switch(Y(e)){case"start":f[c]-=u*(n&&a?-1:1);break;case"end":f[c]+=u*(n&&a?-1:1);break}return f}var bt=async(t,e,n)=>{let{placement:o="bottom",strategy:r="absolute",middleware:l=[],platform:s}=n,c=await(s.isRTL==null?void 0:s.isRTL(e)),i=await s.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:d}=vt(i,o,c),a=o,f={},m=0;for(let p=0;p<l.length;p++){let{name:w,fn:v}=l[p],{x:g,y:h,data:y,reset:x}=await v({x:u,y:d,initialPlacement:o,placement:a,strategy:r,middlewareData:f,rects:i,platform:s,elements:{reference:t,floating:e}});if(u=g??u,d=h??d,f={...f,[w]:{...f[w],...y}},x){typeof x=="object"&&(x.placement&&(a=x.placement),x.rects&&(i=x.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:r}):x.rects),{x:u,y:d}=vt(i,a,c)),p=-1;continue}}return{x:u,y:d,placement:a,strategy:r,middlewareData:f}};function Jt(t){return{top:0,right:0,bottom:0,left:0,...t}}function xt(t){return typeof t!="number"?Jt(t):{top:t,right:t,bottom:t,left:t}}function F(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function X(t,e){var n;e===void 0&&(e={});let{x:o,y:r,platform:l,rects:s,elements:c,strategy:i}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:a="floating",altBoundary:f=!1,padding:m=0}=e,p=xt(m),v=c[f?a==="floating"?"reference":"floating":a],g=F(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(v)))==null||n?v:v.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(c.floating)),boundary:u,rootBoundary:d,strategy:i})),h=F(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({rect:a==="floating"?{...s.floating,x:o,y:r}:s.reference,offsetParent:await(l.getOffsetParent==null?void 0:l.getOffsetParent(c.floating)),strategy:i}):s[a]);return{top:g.top-h.top+p.top,bottom:h.bottom-g.bottom+p.bottom,left:g.left-h.left+p.left,right:h.right-g.right+p.right}}var Zt=Math.min,R=Math.max;function nt(t,e,n){return R(t,Zt(e,n))}var rt=t=>({name:"arrow",options:t,async fn(e){let{element:n,padding:o=0}=t??{},{x:r,y:l,placement:s,rects:c,platform:i}=e;if(n==null)return{};let u=xt(o),d={x:r,y:l},a=B(s),f=ot(a),m=await i.getDimensions(n),p=a==="y"?"top":"left",w=a==="y"?"bottom":"right",v=c.reference[f]+c.reference[a]-d[a]-c.floating[f],g=d[a]-c.reference[a],h=await(i.getOffsetParent==null?void 0:i.getOffsetParent(n)),y=h?a==="y"?h.clientHeight||0:h.clientWidth||0:0,x=v/2-g/2,D=u[p],U=y-m[f]-u[w],I=y/2-m[f]/2+x,N=nt(D,I,U);return{data:{[a]:N,centerOffset:I-N}}}}),Gt={left:"right",right:"left",bottom:"top",top:"bottom"};function K(t){return t.replace(/left|right|bottom|top/g,e=>Gt[e])}function Qt(t,e,n){n===void 0&&(n=!1);let o=Y(t),r=B(t),l=ot(r),s=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(s=K(s)),{main:s,cross:K(s)}}var te={start:"end",end:"start"};function yt(t){return t.replace(/start|end/g,e=>te[e])}function ee(t){let e=K(t);return[yt(t),e,yt(e)]}var it=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n;let{placement:o,middlewareData:r,rects:l,initialPlacement:s,platform:c,elements:i}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:a,fallbackStrategy:f="bestFit",flipAlignment:m=!0,...p}=t,w=H(o),g=a||(w===s||!m?[K(s)]:ee(s)),h=[s,...g],y=await X(e,p),x=[],D=((n=r.flip)==null?void 0:n.overflows)||[];if(u&&x.push(y[w]),d){let{main:z,cross:q}=Qt(o,l,await(c.isRTL==null?void 0:c.isRTL(i.floating)));x.push(y[z],y[q])}if(D=[...D,{placement:o,overflows:x}],!x.every(z=>z<=0)){var U,I;let z=((U=(I=r.flip)==null?void 0:I.index)!=null?U:0)+1,q=h[z];if(q)return{data:{index:z,overflows:D},reset:{placement:q}};let $="bottom";switch(f){case"bestFit":{var N;let wt=(N=D.slice().sort((_t,jt)=>_t.overflows.filter(S=>S>0).reduce((S,tt)=>S+tt,0)-jt.overflows.filter(S=>S>0).reduce((S,tt)=>S+tt,0))[0])==null?void 0:N.placement;wt&&($=wt);break}case"initialPlacement":$=s;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function ne(t,e,n,o){o===void 0&&(o=!1);let r=H(t),l=Y(t),s=B(t)==="x",c=["left","top"].includes(r)?-1:1,i=o&&s?-1:1,u=typeof n=="function"?n({...e,placement:t}):n,d=typeof u=="number",{mainAxis:a,crossAxis:f,alignmentAxis:m}=d?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...u};return l&&typeof m=="number"&&(f=l==="end"?m*-1:m),s?{x:f*i,y:a*c}:{x:a*c,y:f*i}}var lt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:n,y:o,placement:r,rects:l,platform:s,elements:c}=e,i=ne(r,l,t,await(s.isRTL==null?void 0:s.isRTL(c.floating)));return{x:n+i.x,y:o+i.y,data:i}}}};function oe(t){return t==="x"?"y":"x"}var st=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:o,placement:r}=e,{mainAxis:l=!0,crossAxis:s=!1,limiter:c={fn:v=>{let{x:g,y:h}=v;return{x:g,y:h}}},...i}=t,u={x:n,y:o},d=await X(e,i),a=B(H(r)),f=oe(a),m=u[a],p=u[f];if(l){let v=a==="y"?"top":"left",g=a==="y"?"bottom":"right",h=m+d[v],y=m-d[g];m=nt(h,m,y)}if(s){let v=f==="y"?"top":"left",g=f==="y"?"bottom":"right",h=p+d[v],y=p-d[g];p=nt(h,p,y)}let w=c.fn({...e,[a]:m,[f]:p});return{...w,data:{x:w.x-n,y:w.y-o}}}}};var at=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){let{placement:n,rects:o,platform:r,elements:l}=e,{apply:s,...c}=t,i=await X(e,c),u=H(n),d=Y(n),a,f;u==="top"||u==="bottom"?(a=u,f=d===(await(r.isRTL==null?void 0:r.isRTL(l.floating))?"start":"end")?"left":"right"):(f=u,a=d==="end"?"top":"bottom");let m=R(i.left,0),p=R(i.right,0),w=R(i.top,0),v=R(i.bottom,0),g={height:o.floating.height-(["left","right"].includes(n)?2*(w!==0||v!==0?w+v:R(i.top,i.bottom)):i[a]),width:o.floating.width-(["top","bottom"].includes(n)?2*(m!==0||p!==0?m+p:R(i.left,i.right)):i[f])},h=await r.getDimensions(l.floating);s?.({...g,...o});let y=await r.getDimensions(l.floating);return h.width!==y.width||h.height!==y.height?{reset:{rects:!0}}:{}}}};function Pt(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function L(t){if(t==null)return window;if(!Pt(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function j(t){return L(t).getComputedStyle(t)}function A(t){return Pt(t)?"":t?(t.nodeName||"").toLowerCase():""}function E(t){return t instanceof L(t).HTMLElement}function V(t){return t instanceof L(t).Element}function re(t){return t instanceof L(t).Node}function ut(t){let e=L(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Z(t){let{overflow:e,overflowX:n,overflowY:o}=j(t);return/auto|scroll|overlay|hidden/.test(e+o+n)}function ie(t){return["table","td","th"].includes(A(t))}function St(t){let e=navigator.userAgent.toLowerCase().includes("firefox"),n=j(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 Rt(){return!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var Et=Math.min,_=Math.max,J=Math.round;function k(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),r=1,l=1;e&&E(t)&&(r=t.offsetWidth>0&&J(o.width)/t.offsetWidth||1,l=t.offsetHeight>0&&J(o.height)/t.offsetHeight||1);let s=V(t)?L(t):window,c=!Rt()&&n,i=(o.left+(c?s.visualViewport.offsetLeft:0))/r,u=(o.top+(c?s.visualViewport.offsetTop:0))/l,d=o.width/r,a=o.height/l;return{width:d,height:a,top:u,right:i+d,bottom:u+a,left:i,x:i,y:u}}function P(t){return((re(t)?t.ownerDocument:t.document)||window.document).documentElement}function G(t){return V(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function kt(t){return k(P(t)).left+G(t).scrollLeft}function le(t){let e=k(t);return J(e.width)!==t.offsetWidth||J(e.height)!==t.offsetHeight}function se(t,e,n){let o=E(e),r=P(e),l=k(t,o&&le(e),n==="fixed"),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};if(o||!o&&n!=="fixed")if((A(e)!=="body"||Z(r))&&(s=G(e)),E(e)){let i=k(e,!0);c.x=i.x+e.clientLeft,c.y=i.y+e.clientTop}else r&&(c.x=kt(r));return{x:l.left+s.scrollLeft-c.x,y:l.top+s.scrollTop-c.y,width:l.width,height:l.height}}function ft(t){return A(t)==="html"?t:t.assignedSlot||t.parentNode||(ut(t)?t.host:null)||P(t)}function At(t){return!E(t)||getComputedStyle(t).position==="fixed"?null:t.offsetParent}function ae(t){let e=ft(t);for(ut(e)&&(e=e.host);E(e)&&!["html","body"].includes(A(e));){if(St(e))return e;e=e.parentNode}return null}function ct(t){let e=L(t),n=At(t);for(;n&&ie(n)&&getComputedStyle(n).position==="static";)n=At(n);return n&&(A(n)==="html"||A(n)==="body"&&getComputedStyle(n).position==="static"&&!St(n))?e:n||ae(t)||e}function Lt(t){if(E(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=k(t);return{width:e.width,height:e.height}}function ce(t){let{rect:e,offsetParent:n,strategy:o}=t,r=E(n),l=P(n);if(n===l)return e;let s={scrollLeft:0,scrollTop:0},c={x:0,y:0};if((r||!r&&o!=="fixed")&&((A(n)!=="body"||Z(l))&&(s=G(n)),E(n))){let i=k(n,!0);c.x=i.x+n.clientLeft,c.y=i.y+n.clientTop}return{...e,x:e.x-s.scrollLeft+c.x,y:e.y-s.scrollTop+c.y}}function ue(t,e){let n=L(t),o=P(t),r=n.visualViewport,l=o.clientWidth,s=o.clientHeight,c=0,i=0;if(r){l=r.width,s=r.height;let u=Rt();(u||!u&&e==="fixed")&&(c=r.offsetLeft,i=r.offsetTop)}return{width:l,height:s,x:c,y:i}}function fe(t){var e;let n=P(t),o=G(t),r=(e=t.ownerDocument)==null?void 0:e.body,l=_(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=_(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),c=-o.scrollLeft+kt(t),i=-o.scrollTop;return j(r||n).direction==="rtl"&&(c+=_(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:s,x:c,y:i}}function Tt(t){let e=ft(t);return["html","body","#document"].includes(A(e))?t.ownerDocument.body:E(e)&&Z(e)?e:Tt(e)}function Q(t,e){var n;e===void 0&&(e=[]);let o=Tt(t),r=o===((n=t.ownerDocument)==null?void 0:n.body),l=L(o),s=r?[l].concat(l.visualViewport||[],Z(o)?o:[]):o,c=e.concat(s);return r?c:c.concat(Q(ft(s)))}function de(t,e){let n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&ut(n)){let o=e;do{if(o&&t===o)return!0;o=o.parentNode||o.host}while(o)}return!1}function me(t,e){let n=k(t,!1,e==="fixed"),o=n.top+t.clientTop,r=n.left+t.clientLeft;return{top:o,left:r,x:r,y:o,right:r+t.clientWidth,bottom:o+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}function Ot(t,e,n){return e==="viewport"?F(ue(t,n)):V(e)?me(e,n):F(fe(P(t)))}function pe(t){let e=Q(t),o=["absolute","fixed"].includes(j(t).position)&&E(t)?ct(t):t;return V(o)?e.filter(r=>V(r)&&de(r,o)&&A(r)!=="body"):[]}function he(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t,s=[...n==="clippingAncestors"?pe(e):[].concat(n),o],c=s[0],i=s.reduce((u,d)=>{let a=Ot(e,d,r);return u.top=_(a.top,u.top),u.right=Et(a.right,u.right),u.bottom=Et(a.bottom,u.bottom),u.left=_(a.left,u.left),u},Ot(e,c,r));return{width:i.right-i.left,height:i.bottom-i.top,x:i.left,y:i.top}}var ge={getClippingRect:he,convertOffsetParentRelativeRectToViewportRelativeRect:ce,isElement:V,getDimensions:Lt,getOffsetParent:ct,getDocumentElement:P,getElementRects:t=>{let{reference:e,floating:n,strategy:o}=t;return{reference:se(e,ct(n),o),floating:{...Lt(n),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>j(t).direction==="rtl"};var Ct=(t,e,n)=>bt(t,e,{platform:ge,...n});var we=()=>{};var We=(()=>{let t=0;return()=>(t++,t.toString(36))})();var T=new Map,O=new Map;function ve(t,e,n,o){var r;if(!t)return we;let l=JSON.stringify({type:e,options:o}),s=T.get(t);if(T.has(t))s!=null&&s.has(l)?(r=s?.get(l))==null||r.add(n):s?.set(l,new Set([n]));else{let i=new Map([[l,new Set([n])]]);T.set(t,i)}function c(i){var u,d;function a(f){var m;let p=T.get(i);(m=p?.get(l))==null||m.forEach(w=>w(f))}if(!(O!=null&&O.has(i))){O.set(i,new Map([[l,a]])),i.addEventListener(e,a,o);return}(u=O?.get(i))!=null&&u.has(l)||((d=O.get(i))==null||d.set(l,a),i.addEventListener(e,a,o))}return c(t),function(){var i,u,d,a;if(!T.has(t))return;let f=T.get(t);if((i=f?.get(l))==null||i.delete(n),((u=f?.get(l))==null?void 0:u.size)===0){let m=(d=O.get(t))==null?void 0:d.get(l);t.removeEventListener(e,m,o),f?.delete(l),(a=O.get(t))==null||a.delete(l),f?.size===0&&(T.delete(t),O.delete(t))}}}var Mt=t=>Object.prototype.toString.call(t).slice(8,-1),ye=t=>Mt(t)==="Object"&&"current"in t,be=t=>Mt(t)==="Function"?t():t;function mt(t,e,n,o){let r=ye(t)?t.current:be(t);return ve(r,e,n,o)}function Dt(t){var e;return xe(t)?t.document:(e=t?.ownerDocument)!=null?e:document}function pt(t){return typeof t=="object"&&t?.nodeType===Node.ELEMENT_NODE&&typeof t?.nodeName=="string"}function xe(t){return t?.toString()==="[object Window]"}var Ie=["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 C=new Map;function ht(t,e){let n=C.get(t);return n?(n.callbacks.push(e),e(t.getBoundingClientRect())):(C.set(t,{rect:{},callbacks:[e]}),C.size===1&&(dt=requestAnimationFrame(zt))),function(){let o=C.get(t);if(!o)return;let r=o.callbacks.indexOf(e);r>-1&&o.callbacks.splice(r,1),o.callbacks.length===0&&(C.delete(t),C.size===0&&cancelAnimationFrame(dt))}}var dt;function zt(){let t=[];C.forEach((e,n)=>{let o=n.getBoundingClientRect();Ee(e.rect,o)||(e.rect=o,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(n=>n(e.rect))}),dt=requestAnimationFrame(zt)}function Ee(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 gt=()=>{},W=(...t)=>e=>t.reduce((n,o)=>o(n),e);var Fe=(()=>{let t=0;return()=>(t++,t.toString(36))})();var Ht=t=>t===!0||t===!1;function Ae(t){return Ht(t)?{ancestorResize:t,ancestorScroll:t,referenceResize:t}:Object.assign({ancestorResize:!0,ancestorScroll:!0,referenceResize:!0},t)}function Vt(t,e,n,o=!1){let{ancestorScroll:r,ancestorResize:l,referenceResize:s}=Ae(o),c=r||l,i=[];c&&pt(t)&&i.push(...Q(t));function u(){let a=[ht(e,n)];return s&&pt(t)&&a.push(ht(t,n)),a.push(W(...i.map(f=>mt(f,"resize",n)))),()=>a.forEach(f=>f())}function d(){return W(...i.map(a=>mt(a,"scroll",n,{passive:!0})))}return W(u(),d())}var M=t=>({variable:t,reference:`var(${t})`}),b={arrowShadowColor:M("--arrow-shadow-color"),arrowSize:M("--arrow-size"),arrowSizeHalf:M("--arrow-size-half"),arrowBg:M("--arrow-background"),transformOrigin:M("--transform-origin"),arrowOffset:M("--arrow-offset"),boxShadow:M("--arrow-box-shadow")},Wt={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"},It={name:"transformOrigin",fn({placement:t,elements:e}){let{floating:n}=e;return n.style.setProperty(b.transformOrigin.variable,Wt[t]),{data:{transformOrigin:Wt[t]}}}},Nt=t=>({name:"shiftArrow",fn({placement:e,middlewareData:n}){var c;let{element:o}=t,{x:r,y:l}=(c=n.arrow)!=null?c:{x:0,y:0},s={top:"bottom",right:"left",bottom:"top",left:"right"}[e.split("-")[0]];return Object.assign(o.style,{top:`${l}px`,left:`${r}px`,[s]:b.arrowOffset.reference,[b.boxShadow.variable]:Le(e)}),{}}});function Le(t){if(t.includes("top"))return`1px 1px 1px 0 ${b.arrowShadowColor.reference}`;if(t.includes("bottom"))return`-1px -1px 1px 0 ${b.arrowShadowColor.reference}`;if(t.includes("right"))return`-1px 1px 1px 0 ${b.arrowShadowColor.reference}`;if(t.includes("left"))return`1px -1px 1px 0 ${b.arrowShadowColor.reference}`}var Oe={strategy:"absolute",placement:"bottom",listeners:!0,gutter:8,flip:!0,sameWidth:!1};function Ft(t,e,n={}){var c;if(t==null||e==null)return gt;n=Object.assign({},Oe,n);let o=[It];if(n.flip&&o.push(it({boundary:n.boundary,padding:8})),n.gutter||n.offset){let i=n.gutter?{mainAxis:n.gutter}:n.offset;o.push(lt(i))}o.push(st({boundary:n.boundary}));let l=Dt(e).querySelector("[data-part=arrow]");l&&o.push(rt({element:l,padding:8}),Nt({element:l})),n.sameWidth&&o.push(at({apply(i){let{width:u}=i.reference;Object.assign(e.style,{width:`${u}px`,minWidth:"unset"})}}));function s(){if(t==null||e==null)return;let{placement:i,strategy:u}=n;Ct(t,e,{placement:i,middleware:o,strategy:u}).then(d=>{let{x:a,y:f,strategy:m}=d;return Object.assign(e.style,{left:`${a}px`,top:`${f}px`,position:m}),d}).then(d=>{var a;(a=n.onComplete)==null||a.call(n,d)})}return s(),W(Vt(t,e,s,n.listeners),(c=n.onCleanup)!=null?c:gt)}var Pe={position:"fixed",top:0,left:0,opacity:0,transform:"translate3d(0, -200%, 0)",pointerEvents:"none"};function Bt(t){let{measured:e,strategy:n="absolute"}=t;return{arrow:{position:"absolute",width:b.arrowSize.reference,height:b.arrowSize.reference,[b.arrowSizeHalf.variable]:`calc(${b.arrowSize.reference} / 2)`,[b.arrowOffset.variable]:`calc(${b.arrowSizeHalf.reference} * -1)`,opacity:e?void 0:0},innerArrow:{transform:"rotate(45deg)",background:b.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:n,minWidth:"max-content",...!e&&Pe}}}
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
getPlacement: () => getPlacement,
getPlacementStyles: () => getPlacementStyles
});
module.exports = __toCommonJS(src_exports);
// ../../../node_modules/@floating-ui/core/dist/floating-ui.core.esm.js
function getSide(placement) {
return placement.split("-")[0];
}
function getAlignment(placement) {
return placement.split("-")[1];
}
function getMainAxisFromPlacement(placement) {
return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
}
function getLengthFromAxis(axis) {
return axis === "y" ? "height" : "width";
}
function computeCoordsFromPlacement(_ref, placement, rtl) {
let {
reference,
floating
} = _ref;
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
const commonAlign = reference[length] / 2 - floating[length] / 2;
const side = getSide(placement);
const isVertical = mainAxis === "x";
let coords;
switch (side) {
case "top":
coords = {
x: commonX,
y: reference.y - floating.height
};
break;
case "bottom":
coords = {
x: commonX,
y: reference.y + reference.height
};
break;
case "right":
coords = {
x: reference.x + reference.width,
y: commonY
};
break;
case "left":
coords = {
x: reference.x - floating.width,
y: commonY
};
break;
default:
coords = {
x: reference.x,
y: reference.y
};
}
switch (getAlignment(placement)) {
case "start":
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case "end":
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;
}
return coords;
}
var computePosition = (reference, floating, config) => __async(void 0, null, function* () {
const {
placement = "bottom",
strategy = "absolute",
middleware = [],
platform: platform2
} = config;
const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(floating);
if (void 0 !== "production") {
if (platform2 == null) {
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(" "));
}
if (middleware.filter((_ref) => {
let {
name
} = _ref;
return name === "autoPlacement" || name === "flip";
}).length > 1) {
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(" "));
}
}
let rects = yield platform2.getElementRects({
reference,
floating,
strategy
});
let {
x,
y
} = computeCoordsFromPlacement(rects, placement, rtl);
let statefulPlacement = placement;
let middlewareData = {};
let _debug_loop_count_ = 0;
for (let i = 0; i < middleware.length; i++) {
if (void 0 !== "production") {
_debug_loop_count_++;
if (_debug_loop_count_ > 100) {
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(" "));
}
}
const {
name,
fn
} = middleware[i];
const {
x: nextX,
y: nextY,
data,
reset
} = yield fn({
x,
y,
initialPlacement: placement,
placement: statefulPlacement,
strategy,
middlewareData,
rects,
platform: platform2,
elements: {
reference,
floating
}
});
x = nextX != null ? nextX : x;
y = nextY != null ? nextY : y;
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
});
if (reset) {
if (typeof reset === "object") {
if (reset.placement) {
statefulPlacement = reset.placement;
}
if (reset.rects) {
rects = reset.rects === true ? yield platform2.getElementRects({
reference,
floating,
strategy
}) : reset.rects;
}
({
x,
y
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
}
i = -1;
continue;
}
}
return {
x,
y,
placement: statefulPlacement,
strategy,
middlewareData
};
});
function expandPaddingObject(padding) {
return __spreadValues({
top: 0,
right: 0,
bottom: 0,
left: 0
}, padding);
}
function getSideObjectFromPadding(padding) {
return typeof padding !== "number" ? expandPaddingObject(padding) : {
top: padding,
right: padding,
bottom: padding,
left: padding
};
}
function rectToClientRect(rect) {
return __spreadProps(__spreadValues({}, rect), {
top: rect.y,
left: rect.x,
right: rect.x + rect.width,
bottom: rect.y + rect.height
});
}
function detectOverflow(middlewareArguments, options) {
return __async(this, null, function* () {
var _await$platform$isEle;
if (options === void 0) {
options = {};
}
const {
x,
y,
platform: platform2,
rects,
elements,
strategy
} = middlewareArguments;
const {
boundary = "clippingAncestors",
rootBoundary = "viewport",
elementContext = "floating",
altBoundary = false,
padding = 0
} = options;
const paddingObject = getSideObjectFromPadding(padding);
const altContext = elementContext === "floating" ? "reference" : "floating";
const element = elements[altBoundary ? altContext : elementContext];
const clippingClientRect = rectToClientRect(yield platform2.getClippingRect({
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)),
boundary,
rootBoundary,
strategy
}));
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
x,
y
}) : rects.reference,
offsetParent: yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating),
strategy
}) : rects[elementContext]);
return {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
};
});
}
var min = Math.min;
var max = Math.max;
function within(min$1, value, max$1) {
return max(min$1, min(value, max$1));
}
var arrow = (options) => ({
name: "arrow",
options,
fn(middlewareArguments) {
return __async(this, null, function* () {
const {
element,
padding = 0
} = options != null ? options : {};
const {
x,
y,
placement,
rects,
platform: platform2
} = middlewareArguments;
if (element == null) {
if (void 0 !== "production") {
console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
}
return {};
}
const paddingObject = getSideObjectFromPadding(padding);
const coords = {
x,
y
};
const axis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(axis);
const arrowDimensions = yield platform2.getDimensions(element);
const minProp = axis === "y" ? "top" : "left";
const maxProp = axis === "y" ? "bottom" : "right";
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element);
const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
const centerToReference = endDiff / 2 - startDiff / 2;
const min3 = paddingObject[minProp];
const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset2 = within(min3, center, max3);
return {
data: {
[axis]: offset2,
centerOffset: center - offset2
}
};
});
}
});
var hash$1 = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
}
function getAlignmentSides(placement, rects, rtl) {
if (rtl === void 0) {
rtl = false;
}
const alignment = getAlignment(placement);
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
if (rects.reference[length] > rects.floating[length]) {
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
}
return {
main: mainAlignmentSide,
cross: getOppositePlacement(mainAlignmentSide)
};
}
var hash = {
start: "end",
end: "start"
};
function getOppositeAlignmentPlacement(placement) {
return placement.replace(/start|end/g, (matched) => hash[matched]);
}
function getExpandedPlacements(placement) {
const oppositePlacement = getOppositePlacement(placement);
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
}
var flip = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "flip",
options,
fn(middlewareArguments) {
return __async(this, null, function* () {
var _middlewareData$flip;
const {
placement,
middlewareData,
rects,
initialPlacement,
platform: platform2,
elements
} = middlewareArguments;
const _a2 = options, {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true,
fallbackPlacements: specifiedFallbackPlacements,
fallbackStrategy = "bestFit",
flipAlignment = true
} = _a2, detectOverflowOptions = __objRest(_a2, [
"mainAxis",
"crossAxis",
"fallbackPlacements",
"fallbackStrategy",
"flipAlignment"
]);
const side = getSide(placement);
const isBasePlacement = side === initialPlacement;
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
const placements = [initialPlacement, ...fallbackPlacements];
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
const overflows = [];
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
if (checkMainAxis) {
overflows.push(overflow[side]);
}
if (checkCrossAxis) {
const {
main,
cross
} = getAlignmentSides(placement, rects, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
overflows.push(overflow[main], overflow[cross]);
}
overflowsData = [...overflowsData, {
placement,
overflows
}];
if (!overflows.every((side2) => side2 <= 0)) {
var _middlewareData$flip$, _middlewareData$flip2;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];
if (nextPlacement) {
return {
data: {
index: nextIndex,
overflows: overflowsData
},
reset: {
placement: nextPlacement
}
};
}
let resetPlacement = "bottom";
switch (fallbackStrategy) {
case "bestFit": {
var _overflowsData$slice$;
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;
if (placement2) {
resetPlacement = placement2;
}
break;
}
case "initialPlacement":
resetPlacement = initialPlacement;
break;
}
if (placement !== resetPlacement) {
return {
reset: {
placement: resetPlacement
}
};
}
}
return {};
});
}
};
};
function convertValueToCoords(placement, rects, value, rtl) {
if (rtl === void 0) {
rtl = false;
}
const side = getSide(placement);
const alignment = getAlignment(placement);
const isVertical = getMainAxisFromPlacement(placement) === "x";
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = typeof value === "function" ? value(__spreadProps(__spreadValues({}, rects), {
placement
})) : value;
const isNumber = typeof rawValue === "number";
let {
mainAxis,
crossAxis,
alignmentAxis
} = isNumber ? {
mainAxis: rawValue,
crossAxis: 0,
alignmentAxis: null
} : __spreadValues({
mainAxis: 0,
crossAxis: 0,
alignmentAxis: null
}, rawValue);
if (alignment && typeof alignmentAxis === "number") {
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
}
return isVertical ? {
x: crossAxis * crossAxisMulti,
y: mainAxis * mainAxisMulti
} : {
x: mainAxis * mainAxisMulti,
y: crossAxis * crossAxisMulti
};
}
var offset = function(value) {
if (value === void 0) {
value = 0;
}
return {
name: "offset",
options: value,
fn(middlewareArguments) {
return __async(this, null, function* () {
const {
x,
y,
placement,
rects,
platform: platform2,
elements
} = middlewareArguments;
const diffCoords = convertValueToCoords(placement, rects, value, yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
return {
x: x + diffCoords.x,
y: y + diffCoords.y,
data: diffCoords
};
});
}
};
};
function getCrossAxis(axis) {
return axis === "x" ? "y" : "x";
}
var shift = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "shift",
options,
fn(middlewareArguments) {
return __async(this, null, function* () {
const {
x,
y,
placement
} = middlewareArguments;
const _a2 = options, {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = false,
limiter = {
fn: (_ref) => {
let {
x: x2,
y: y2
} = _ref;
return {
x: x2,
y: y2
};
}
}
} = _a2, detectOverflowOptions = __objRest(_a2, [
"mainAxis",
"crossAxis",
"limiter"
]);
const coords = {
x,
y
};
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
const mainAxis = getMainAxisFromPlacement(getSide(placement));
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
if (checkMainAxis) {
const minSide = mainAxis === "y" ? "top" : "left";
const maxSide = mainAxis === "y" ? "bottom" : "right";
const min3 = mainAxisCoord + overflow[minSide];
const max3 = mainAxisCoord - overflow[maxSide];
mainAxisCoord = within(min3, mainAxisCoord, max3);
}
if (checkCrossAxis) {
const minSide = crossAxis === "y" ? "top" : "left";
const maxSide = crossAxis === "y" ? "bottom" : "right";
const min3 = crossAxisCoord + overflow[minSide];
const max3 = crossAxisCoord - overflow[maxSide];
crossAxisCoord = within(min3, crossAxisCoord, max3);
}
const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, middlewareArguments), {
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
}));
return __spreadProps(__spreadValues({}, limitedCoords), {
data: {
x: limitedCoords.x - x,
y: limitedCoords.y - y
}
});
});
}
};
};
var size = function(options) {
if (options === void 0) {
options = {};
}
return {
name: "size",
options,
fn(middlewareArguments) {
return __async(this, null, function* () {
const {
placement,
rects,
platform: platform2,
elements
} = middlewareArguments;
const _a2 = options, {
apply
} = _a2, detectOverflowOptions = __objRest(_a2, [
"apply"
]);
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
const side = getSide(placement);
const alignment = getAlignment(placement);
let heightSide;
let widthSide;
if (side === "top" || side === "bottom") {
heightSide = side;
widthSide = alignment === ((yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
} else {
widthSide = side;
heightSide = alignment === "end" ? "top" : "bottom";
}
const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
const dimensions = {
height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
};
const prevDimensions = yield platform2.getDimensions(elements.floating);
apply == null ? void 0 : apply(__spreadValues(__spreadValues({}, dimensions), rects));
const nextDimensions = yield platform2.getDimensions(elements.floating);
if (prevDimensions.width !== nextDimensions.width || prevDimensions.height !== nextDimensions.height) {
return {
reset: {
rects: true
}
};
}
return {};
});
}
};
};
// ../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
function isWindow(value) {
return value && value.document && value.location && value.alert && value.setInterval;
}
function getWindow(node) {
if (node == null) {
return window;
}
if (!isWindow(node)) {
const ownerDocument = node.ownerDocument;
return ownerDocument ? ownerDocument.defaultView || window : window;
}
return node;
}
function getComputedStyle$1(element) {
return getWindow(element).getComputedStyle(element);
}
function getNodeName(node) {
return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
}
function isHTMLElement(value) {
return value instanceof getWindow(value).HTMLElement;
}
function isElement(value) {
return value instanceof getWindow(value).Element;
}
function isNode(value) {
return value instanceof getWindow(value).Node;
}
function isShadowRoot(node) {
const OwnElement = getWindow(node).ShadowRoot;
return node instanceof OwnElement || node instanceof ShadowRoot;
}
function isOverflowElement(element) {
const {
overflow,
overflowX,
overflowY
} = getComputedStyle$1(element);
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
}
function isTableElement(element) {
return ["table", "td", "th"].includes(getNodeName(element));
}
function isContainingBlock(element) {
const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
const css = getComputedStyle$1(element);
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);
}
function isLayoutViewport() {
return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
}
var min2 = Math.min;
var max2 = Math.max;
var round = Math.round;
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
if (includeScale === void 0) {
includeScale = false;
}
if (isFixedStrategy === void 0) {
isFixedStrategy = false;
}
const clientRect = element.getBoundingClientRect();
let scaleX = 1;
let scaleY = 1;
if (includeScale && isHTMLElement(element)) {
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
}
const win = isElement(element) ? getWindow(element) : window;
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
const width = clientRect.width / scaleX;
const height = clientRect.height / scaleY;
return {
width,
height,
top: y,
right: x + width,
bottom: y + height,
left: x,
x,
y
};
}
function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function getNodeScroll(element) {
if (isElement(element)) {
return {
scrollLeft: element.scrollLeft,
scrollTop: element.scrollTop
};
}
return {
scrollLeft: element.pageXOffset,
scrollTop: element.pageYOffset
};
}
function getWindowScrollBarX(element) {
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
}
function isScaled(element) {
const rect = getBoundingClientRect(element);
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
}
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === "fixed");
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
}
function getParentNode(node) {
if (getNodeName(node) === "html") {
return node;
}
return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
}
function getTrueOffsetParent(element) {
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
return null;
}
return element.offsetParent;
}
function getContainingBlock(element) {
let currentNode = getParentNode(element);
if (isShadowRoot(currentNode)) {
currentNode = currentNode.host;
}
while (isHTMLElement(currentNode) && !["html", "body"].includes(getNodeName(currentNode))) {
if (isContainingBlock(currentNode)) {
return currentNode;
} else {
currentNode = currentNode.parentNode;
}
}
return null;
}
function getOffsetParent(element) {
const window2 = getWindow(element);
let offsetParent = getTrueOffsetParent(element);
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
offsetParent = getTrueOffsetParent(offsetParent);
}
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
return window2;
}
return offsetParent || getContainingBlock(element) || window2;
}
function getDimensions(element) {
if (isHTMLElement(element)) {
return {
width: element.offsetWidth,
height: element.offsetHeight
};
}
const rect = getBoundingClientRect(element);
return {
width: rect.width,
height: rect.height
};
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
let {
rect,
offsetParent,
strategy
} = _ref;
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
if (offsetParent === documentElement) {
return rect;
}
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
}
}
return __spreadProps(__spreadValues({}, rect), {
x: rect.x - scroll.scrollLeft + offsets.x,
y: rect.y - scroll.scrollTop + offsets.y
});
}
function getViewportRect(element, strategy) {
const win = getWindow(element);
const html = getDocumentElement(element);
const visualViewport = win.visualViewport;
let width = html.clientWidth;
let height = html.clientHeight;
let x = 0;
let y = 0;
if (visualViewport) {
width = visualViewport.width;
height = visualViewport.height;
const layoutViewport = isLayoutViewport();
if (layoutViewport || !layoutViewport && strategy === "fixed") {
x = visualViewport.offsetLeft;
y = visualViewport.offsetTop;
}
}
return {
width,
height,
x,
y
};
}
function getDocumentRect(element) {
var _element$ownerDocumen;
const html = getDocumentElement(element);
const scroll = getNodeScroll(element);
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
const width = max2(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
const height = max2(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
const y = -scroll.scrollTop;
if (getComputedStyle$1(body || html).direction === "rtl") {
x += max2(html.clientWidth, body ? body.clientWidth : 0) - width;
}
return {
width,
height,
x,
y
};
}
function getNearestOverflowAncestor(node) {
const parentNode = getParentNode(node);
if (["html", "body", "#document"].includes(getNodeName(parentNode))) {
return node.ownerDocument.body;
}
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
return parentNode;
}
return getNearestOverflowAncestor(parentNode);
}
function getOverflowAncestors(node, list) {
var _node$ownerDocument;
if (list === void 0) {
list = [];
}
const scrollableAncestor = getNearestOverflowAncestor(node);
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
const win = getWindow(scrollableAncestor);
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
const updatedList = list.concat(target);
return isBody ? updatedList : updatedList.concat(getOverflowAncestors(getParentNode(target)));
}
function contains(parent, child) {
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
if (parent.contains(child)) {
return true;
} else if (rootNode && isShadowRoot(rootNode)) {
let next = child;
do {
if (next && parent === next) {
return true;
}
next = next.parentNode || next.host;
} while (next);
}
return false;
}
function getInnerBoundingClientRect(element, strategy) {
const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
const top = clientRect.top + element.clientTop;
const left = clientRect.left + element.clientLeft;
return {
top,
left,
x: left,
y: top,
right: left + element.clientWidth,
bottom: top + element.clientHeight,
width: element.clientWidth,
height: element.clientHeight
};
}
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
if (clippingParent === "viewport") {
return rectToClientRect(getViewportRect(element, strategy));
}
if (isElement(clippingParent)) {
return getInnerBoundingClientRect(clippingParent, strategy);
}
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
}
function getClippingAncestors(element) {
const clippingAncestors = getOverflowAncestors(element);
const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element).position);
const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
if (!isElement(clipperElement)) {
return [];
}
return clippingAncestors.filter((clippingAncestors2) => isElement(clippingAncestors2) && contains(clippingAncestors2, clipperElement) && getNodeName(clippingAncestors2) !== "body");
}
function getClippingRect(_ref) {
let {
element,
boundary,
rootBoundary,
strategy
} = _ref;
const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
const firstClippingAncestor = clippingAncestors[0];
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
accRect.top = max2(rect.top, accRect.top);
accRect.right = min2(rect.right, accRect.right);
accRect.bottom = min2(rect.bottom, accRect.bottom);
accRect.left = max2(rect.left, accRect.left);
return accRect;
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
return {
width: clippingRect.right - clippingRect.left,
height: clippingRect.bottom - clippingRect.top,
x: clippingRect.left,
y: clippingRect.top
};
}
var platform = {
getClippingRect,
convertOffsetParentRelativeRectToViewportRelativeRect,
isElement,
getDimensions,
getOffsetParent,
getDocumentElement,
getElementRects: (_ref) => {
let {
reference,
floating,
strategy
} = _ref;
return {
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
floating: __spreadProps(__spreadValues({}, getDimensions(floating)), {
x: 0,
y: 0
})
};
},
getClientRects: (element) => Array.from(element.getClientRects()),
isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
};
var computePosition2 = (reference, floating, options) => computePosition(reference, floating, __spreadValues({
platform
}, options));
// ../core/src/functions.ts
var noop = () => {
};
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
// ../core/src/guard.ts
var isBoolean = (v) => v === true || v === false;
// ../dom/src/event-bus.ts
var listenerElements = /* @__PURE__ */ new Map();
var listenerCache = /* @__PURE__ */ new Map();
function globalEventBus(node, type, handler, options) {
var _a;
if (!node)
return noop;
const hash2 = JSON.stringify({ type, options });
const group = listenerElements.get(node);
if (!listenerElements.has(node)) {
const group2 = /* @__PURE__ */ new Map([[hash2, /* @__PURE__ */ new Set([handler])]]);
listenerElements.set(node, group2);
} else if (group == null ? void 0 : group.has(hash2)) {
(_a = group == null ? void 0 : group.get(hash2)) == null ? void 0 : _a.add(handler);
} else {
group == null ? void 0 : group.set(hash2, /* @__PURE__ */ new Set([handler]));
}
function attach(node2) {
var _a2, _b;
function listener(event) {
var _a3;
const group2 = listenerElements.get(node2);
(_a3 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a3.forEach((fn) => fn(event));
}
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash2, listener]]));
node2.addEventListener(type, listener, options);
return;
}
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash2))) {
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash2, listener);
node2.addEventListener(type, listener, options);
}
}
attach(node);
return function remove() {
var _a2, _b, _c, _d;
if (!listenerElements.has(node))
return;
const group2 = listenerElements.get(node);
(_a2 = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _a2.delete(handler);
if (((_b = group2 == null ? void 0 : group2.get(hash2)) == null ? void 0 : _b.size) === 0) {
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash2);
node.removeEventListener(type, listener, options);
group2 == null ? void 0 : group2.delete(hash2);
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash2);
if ((group2 == null ? void 0 : group2.size) === 0) {
listenerElements.delete(node);
listenerCache.delete(node);
}
}
};
}
// ../dom/src/listener.ts
var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
var isRef = (v) => t(v) === "Object" && "current" in v;
var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
function addDomEvent(target, event, listener, options) {
const node = isRef(target) ? target.current : runIfFn(target);
return globalEventBus(node, event, listener, options);
}
// ../dom/src/query.ts
function getOwnerDocument(el) {
var _a;
if (isWindow2(el))
return el.document;
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
}
function isHTMLElement2(v) {
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
}
function isWindow2(value) {
return (value == null ? void 0 : value.toString()) === "[object Window]";
}
// ../dom/src/rect-observer.ts
var observedElements = /* @__PURE__ */ new Map();
function observeElementRect(el, fn) {
const data = observedElements.get(el);
if (!data) {
observedElements.set(el, { rect: {}, callbacks: [fn] });
if (observedElements.size === 1) {
rafId = requestAnimationFrame(runLoop);
}
} else {
data.callbacks.push(fn);
fn(el.getBoundingClientRect());
}
return function unobserve() {
const data2 = observedElements.get(el);
if (!data2)
return;
const index = data2.callbacks.indexOf(fn);
if (index > -1) {
data2.callbacks.splice(index, 1);
}
if (data2.callbacks.length === 0) {
observedElements.delete(el);
if (observedElements.size === 0) {
cancelAnimationFrame(rafId);
}
}
};
}
var rafId;
function runLoop() {
const changedRectsData = [];
observedElements.forEach((data, element) => {
const newRect = element.getBoundingClientRect();
if (!isEqual(data.rect, newRect)) {
data.rect = newRect;
changedRectsData.push(data);
}
});
changedRectsData.forEach((data) => {
data.callbacks.forEach((callback) => callback(data.rect));
});
rafId = requestAnimationFrame(runLoop);
}
function isEqual(rect1, rect2) {
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;
}
// src/auto-update.ts
function resolveOptions(option) {
if (isBoolean(option))
return { ancestorResize: option, ancestorScroll: option, referenceResize: option };
return Object.assign({ ancestorResize: true, ancestorScroll: true, referenceResize: true }, option);
}
function autoUpdate(reference, floating, update, options = false) {
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
const useAncestors = ancestorScroll || ancestorResize;
const ancestors = [];
if (useAncestors && isHTMLElement2(reference)) {
ancestors.push(...getOverflowAncestors(reference));
}
function addResizeListeners() {
let cleanups = [observeElementRect(floating, update)];
if (referenceResize && isHTMLElement2(reference)) {
cleanups.push(observeElementRect(reference, update));
}
cleanups.push(pipe(...ancestors.map((el) => addDomEvent(el, "resize", update))));
return () => cleanups.forEach((fn) => fn());
}
function addScrollListeners() {
return pipe(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
}
return pipe(addResizeListeners(), addScrollListeners());
}
// src/middleware.ts
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
var cssVars = {
arrowShadowColor: toVar("--arrow-shadow-color"),
arrowSize: toVar("--arrow-size"),
arrowSizeHalf: toVar("--arrow-size-half"),
arrowBg: toVar("--arrow-background"),
transformOrigin: toVar("--transform-origin"),
arrowOffset: toVar("--arrow-offset"),
boxShadow: toVar("--arrow-box-shadow")
};
var transforms = {
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"
};
var transformOrigin = {
name: "transformOrigin",
fn({ placement, elements }) {
const { floating } = elements;
floating.style.setProperty(cssVars.transformOrigin.variable, transforms[placement]);
return {
data: { transformOrigin: transforms[placement] }
};
}
};
var shiftArrow = (opts) => ({
name: "shiftArrow",
fn({ placement, middlewareData }) {
var _a;
const { element: arrow2 } = opts;
const { x, y } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
const staticSide = {
top: "bottom",
right: "left",
bottom: "top",
left: "right"
}[placement.split("-")[0]];
Object.assign(arrow2.style, {
top: `${y}px`,
left: `${x}px`,
[staticSide]: cssVars.arrowOffset.reference,
[cssVars.boxShadow.variable]: getBoxShadow(placement)
});
return {};
}
});
function getBoxShadow(placement) {
if (placement.includes("top"))
return `1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
if (placement.includes("bottom"))
return `-1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
if (placement.includes("right"))
return `-1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
if (placement.includes("left"))
return `1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
}
// src/get-placement.ts
var defaultOptions = {
strategy: "absolute",
placement: "bottom",
listeners: true,
gutter: 8,
flip: true,
sameWidth: false
};
function getPlacement(reference, floating, options = {}) {
var _a;
if (reference == null || floating == null)
return noop;
options = Object.assign({}, defaultOptions, options);
const middleware = [transformOrigin];
if (options.flip) {
middleware.push(flip({ boundary: options.boundary, padding: 8 }));
}
if (options.gutter || options.offset) {
const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
middleware.push(offset(data));
}
middleware.push(shift({ boundary: options.boundary }));
const doc = getOwnerDocument(floating);
const arrowEl = doc.querySelector("[data-part=arrow]");
if (arrowEl) {
middleware.push(arrow({ element: arrowEl, padding: 8 }), shiftArrow({ element: arrowEl }));
}
if (options.sameWidth) {
middleware.push(size({
apply(data) {
const { width } = data.reference;
Object.assign(floating.style, { width: `${width}px`, minWidth: "unset" });
}
}));
}
function compute() {
if (reference == null || floating == null)
return;
const { placement, strategy } = options;
computePosition2(reference, floating, { placement, middleware, strategy }).then((data) => {
const { x, y, strategy: strategy2 } = data;
Object.assign(floating.style, { left: `${x}px`, top: `${y}px`, position: strategy2 });
return data;
}).then((data) => {
var _a2;
(_a2 = options.onComplete) == null ? void 0 : _a2.call(options, data);
});
}
compute();
return pipe(autoUpdate(reference, floating, compute, options.listeners), (_a = options.onCleanup) != null ? _a : noop);
}
// src/get-styles.ts
var UNMEASURED_FLOATING_STYLE = {
position: "fixed",
top: 0,
left: 0,
opacity: 0,
transform: "translate3d(0, -200%, 0)",
pointerEvents: "none"
};
function getPlacementStyles(options) {
const { measured, strategy = "absolute" } = options;
return {
arrow: {
position: "absolute",
width: cssVars.arrowSize.reference,
height: cssVars.arrowSize.reference,
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
opacity: !measured ? 0 : void 0
},
innerArrow: {
transform: "rotate(45deg)",
background: cssVars.arrowBg.reference,
top: "0",
left: "0",
width: "100%",
height: "100%",
position: "absolute",
zIndex: "inherit"
},
floating: __spreadValues({
position: strategy,
minWidth: "max-content"
}, !measured && UNMEASURED_FLOATING_STYLE)
};
}
//# sourceMappingURL=index.js.map

@@ -39,1 +39,2 @@ import { Middleware, Placement } from "@floating-ui/dom";

export {};
//# sourceMappingURL=middleware.d.ts.map

@@ -49,1 +49,2 @@ import type { Boundary, Placement, ComputePositionReturn } from "@floating-ui/dom";

};
//# sourceMappingURL=types.d.ts.map

19

package.json
{
"name": "@zag-js/popper",
"version": "0.0.0-dev-20220413091534",
"version": "0.0.0-dev-20220413174154",
"description": "Dynamic positioning logic for ui machines",

@@ -19,3 +19,3 @@ "keywords": [

"files": [
"dist"
"dist/**/*"
],

@@ -30,5 +30,14 @@ "publishConfig": {

"@floating-ui/dom": "^0.4.2",
"@zag-js/dom-utils": "^0.0.0-dev-20220413091534",
"@zag-js/utils": "^0.0.0-dev-20220413091534"
"@zag-js/dom-utils": "^0.0.0-dev-20220413174154",
"@zag-js/utils": "^0.0.0-dev-20220413174154"
},
"scripts": {
"build:fast": "zag build",
"start": "zag build --watch",
"build": "zag build --prod",
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
"lint": "eslint src --ext .ts,.tsx",
"test:ci": "yarn test --ci --runInBand",
"test:watch": "yarn test --watch --updateSnapshot"
}
}
}

@@ -15,6 +15,6 @@ # @zag-js/popper

Yes please! See the [contributing guidelines](https://github.com/chakra-ui/core/blob/main/CONTRIBUTING.md) for details.
Yes please! See the [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md) for details.
## Licence
This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/core/blob/main/LICENSE).
This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet