Socket
Socket
Sign inDemoInstall

@floating-ui/core

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/core - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

3

dist/floating-ui.core.esm.development.js

@@ -263,3 +263,4 @@ function getSide(placement) {

boundary,
rootBoundary
rootBoundary,
strategy
}));

@@ -266,0 +267,0 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

@@ -263,3 +263,4 @@ function getSide(placement) {

boundary,
rootBoundary
rootBoundary,
strategy
}));

@@ -266,0 +267,0 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

@@ -1,1 +0,1 @@

function t(t){return t.split("-")[0]}function e(t){return t.split("-")[1]}function n(e){return["top","bottom"].includes(t(e))?"x":"y"}function r(t){return"y"===t?"height":"width"}function i(i,o,l){let{reference:a,floating:s}=i;const c=a.x+a.width/2-s.width/2,f=a.y+a.height/2-s.height/2,u=n(o),m=r(u),g=a[m]/2-s[m]/2,d="x"===u;let p;switch(t(o)){case"top":p={x:c,y:a.y-s.height};break;case"bottom":p={x:c,y:a.y+a.height};break;case"right":p={x:a.x+a.width,y:f};break;case"left":p={x:a.x-s.width,y:f};break;default:p={x:a.x,y:a.y}}switch(e(o)){case"start":p[u]-=g*(l&&d?-1:1);break;case"end":p[u]+=g*(l&&d?-1:1)}return p}const o=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:l=[],platform:a}=n,s=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:f,y:u}=i(c,r,s),m=r,g={};for(let n=0;n<l.length;n++){const{name:d,fn:p}=l[n],{x:h,y:y,data:x,reset:w}=await p({x:f,y:u,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:c,platform:a,elements:{reference:t,floating:e}});f=null!=h?h:f,u=null!=y?y:u,g={...g,[d]:{...g[d],...x}},w&&("object"==typeof w&&(w.placement&&(m=w.placement),w.rects&&(c=!0===w.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):w.rects),({x:f,y:u}=i(c,m,s))),n=-1)}return{x:f,y:u,placement:m,strategy:o,middlewareData:g}};function l(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function a(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function s(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:o,rects:s,elements:c,strategy:f}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:g="floating",altBoundary:d=!1,padding:p=0}=e,h=l(p),y=c[d?"floating"===g?"reference":"floating":g],x=a(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(y)))||n?y:y.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(c.floating)),boundary:u,rootBoundary:m})),w=a(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===g?{...s.floating,x:r,y:i}:s.reference,offsetParent:await(null==o.getOffsetParent?void 0:o.getOffsetParent(c.floating)),strategy:f}):s[g]);return{top:x.top-w.top+h.top,bottom:w.bottom-x.bottom+h.bottom,left:x.left-w.left+h.left,right:w.right-x.right+h.right}}const c=Math.min,f=Math.max;function u(t,e,n){return f(t,c(e,n))}const m=t=>({name:"arrow",options:t,async fn(e){const{element:i,padding:o=0}=null!=t?t:{},{x:a,y:s,placement:c,rects:f,platform:m}=e;if(null==i)return{};const g=l(o),d={x:a,y:s},p=n(c),h=r(p),y=await m.getDimensions(i),x="y"===p?"top":"left",w="y"===p?"bottom":"right",v=f.reference[h]+f.reference[p]-d[p]-f.floating[h],b=d[p]-f.reference[p],R=await(null==m.getOffsetParent?void 0:m.getOffsetParent(i)),A=R?"y"===p?R.clientHeight||0:R.clientWidth||0:0,P=v/2-b/2,T=g[x],O=A-y[h]-g[w],D=A/2-y[h]/2+P,L=u(T,D,O);return{data:{[p]:L,centerOffset:D-L}}}}),g={left:"right",right:"left",bottom:"top",top:"bottom"};function d(t){return t.replace(/left|right|bottom|top/g,(t=>g[t]))}function p(t,i,o){void 0===o&&(o=!1);const l=e(t),a=n(t),s=r(a);let c="x"===a?l===(o?"end":"start")?"right":"left":"start"===l?"bottom":"top";return i.reference[s]>i.floating[s]&&(c=d(c)),{main:c,cross:d(c)}}const h={start:"end",end:"start"};function y(t){return t.replace(/start|end/g,(t=>h[t]))}const x=["top","right","bottom","left"],w=x.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);const v=function(n){return void 0===n&&(n={}),{name:"autoPlacement",options:n,async fn(r){var i,o,l,a,c;const{x:f,y:u,rects:m,middlewareData:g,placement:d,platform:h,elements:x}=r,{alignment:v=null,allowedPlacements:b=w,autoAlignment:R=!0,...A}=n,P=function(n,r,i){return(n?[...i.filter((t=>e(t)===n)),...i.filter((t=>e(t)!==n))]:i.filter((e=>t(e)===e))).filter((t=>!n||e(t)===n||!!r&&y(t)!==t))}(v,R,b),T=await s(r,A),O=null!=(i=null==(o=g.autoPlacement)?void 0:o.index)?i:0,D=P[O];if(null==D)return{};const{main:L,cross:k}=p(D,m,await(null==h.isRTL?void 0:h.isRTL(x.floating)));if(d!==D)return{x:f,y:u,reset:{placement:P[0]}};const E=[T[t(D)],T[L],T[k]],C=[...null!=(l=null==(a=g.autoPlacement)?void 0:a.overflows)?l:[],{placement:D,overflows:E}],B=P[O+1];if(B)return{data:{index:O+1,overflows:C},reset:{placement:B}};const H=C.slice().sort(((t,e)=>t.overflows[0]-e.overflows[0])),V=null==(c=H.find((t=>{let{overflows:e}=t;return e.every((t=>t<=0))})))?void 0:c.placement,F=null!=V?V:H[0].placement;return F!==d?{data:{index:O+1,overflows:C},reset:{placement:F}}:{}}}};const b=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(n){var r;const{placement:i,middlewareData:o,rects:l,initialPlacement:a,platform:c,elements:f}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:h="bestFit",flipAlignment:x=!0,...w}=e,v=t(i),b=g||(v===a||!x?[d(a)]:function(t){const e=d(t);return[y(t),e,y(e)]}(a)),R=[a,...b],A=await s(n,w),P=[];let T=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&P.push(A[v]),m){const{main:t,cross:e}=p(i,l,await(null==c.isRTL?void 0:c.isRTL(f.floating)));P.push(A[t],A[e])}if(T=[...T,{placement:i,overflows:P}],!P.every((t=>t<=0))){var O,D;const t=(null!=(O=null==(D=o.flip)?void 0:D.index)?O:0)+1,e=R[t];if(e)return{data:{index:t,overflows:T},reset:{placement:e}};let n="bottom";switch(h){case"bestFit":{var L;const t=null==(L=T.slice().sort(((t,e)=>t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)-e.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)))[0])?void 0:L.placement;t&&(n=t);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}};function R(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function A(t){return x.some((e=>t[e]>=0))}const P=function(t){let{strategy:e="referenceHidden",...n}=void 0===t?{}:t;return{name:"hide",async fn(t){const{rects:r}=t;switch(e){case"referenceHidden":{const e=R(await s(t,{...n,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:A(e)}}}case"escaped":{const e=R(await s(t,{...n,altBoundary:!0}),r.floating);return{data:{escapedOffsets:e,escaped:A(e)}}}default:return{}}}}};const T=function(r){return void 0===r&&(r=0),{name:"offset",options:r,async fn(i){const{x:o,y:l,placement:a,rects:s,platform:c,elements:f}=i,u=function(r,i,o,l){void 0===l&&(l=!1);const a=t(r),s=e(r),c="x"===n(r),f=["left","top"].includes(a)?-1:1,u=l&&c?-1:1,m="function"==typeof o?o({...i,placement:r}):o,g="number"==typeof m;let{mainAxis:d,crossAxis:p,alignmentAxis:h}=g?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...m};return s&&"number"==typeof h&&(p="end"===s?-1*h:h),c?{x:p*u,y:d*f}:{x:d*f,y:p*u}}(a,s,r,await(null==c.isRTL?void 0:c.isRTL(f.floating)));return{x:o+u.x,y:l+u.y,data:u}}}};function O(t){return"x"===t?"y":"x"}const D=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(r){const{x:i,y:o,placement:l}=r,{mainAxis:a=!0,crossAxis:c=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=e,g={x:i,y:o},d=await s(r,m),p=n(t(l)),h=O(p);let y=g[p],x=g[h];if(a){const t="y"===p?"bottom":"right";y=u(y+d["y"===p?"top":"left"],y,y-d[t])}if(c){const t="y"===h?"bottom":"right";x=u(x+d["y"===h?"top":"left"],x,x-d[t])}const w=f.fn({...r,[p]:y,[h]:x});return{...w,data:{x:w.x-i,y:w.y-o}}}}},L=function(e){return void 0===e&&(e={}),{options:e,fn(r){const{x:i,y:o,placement:l,rects:a,middlewareData:s}=r,{offset:c=0,mainAxis:f=!0,crossAxis:u=!0}=e,m={x:i,y:o},g=n(l),d=O(g);let p=m[g],h=m[d];const y="function"==typeof c?c({...a,placement:l}):c,x="number"==typeof y?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(f){const t="y"===g?"height":"width",e=a.reference[g]-a.floating[t]+x.mainAxis,n=a.reference[g]+a.reference[t]-x.mainAxis;p<e?p=e:p>n&&(p=n)}if(u){var w,v,b,R;const e="y"===g?"width":"height",n=["top","left"].includes(t(l)),r=a.reference[d]-a.floating[e]+(n&&null!=(w=null==(v=s.offset)?void 0:v[d])?w:0)+(n?0:x.crossAxis),i=a.reference[d]+a.reference[e]+(n?0:null!=(b=null==(R=s.offset)?void 0:R[d])?b:0)-(n?x.crossAxis:0);h<r?h=r:h>i&&(h=i)}return{[g]:p,[d]:h}}}},k=function(n){return void 0===n&&(n={}),{name:"size",options:n,async fn(r){const{placement:i,rects:o,platform:l,elements:a}=r,{apply:c,...u}=n,m=await s(r,u),g=t(i),d=e(i);let p,h;"top"===g||"bottom"===g?(p=g,h=d===(await(null==l.isRTL?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(h=g,p="end"===d?"top":"bottom");const y=f(m.left,0),x=f(m.right,0),w=f(m.top,0),v=f(m.bottom,0),b={height:o.floating.height-(["left","right"].includes(i)?2*(0!==w||0!==v?w+v:f(m.top,m.bottom)):m[p]),width:o.floating.width-(["top","bottom"].includes(i)?2*(0!==y||0!==x?y+x:f(m.left,m.right)):m[h])},R=await l.getDimensions(a.floating);null==c||c({...b,...o});const A=await l.getDimensions(a.floating);return R.width!==A.width||R.height!==A.height?{reset:{rects:!0}}:{}}}},E=function(e){return void 0===e&&(e={}),{name:"inline",options:e,async fn(r){var i;const{placement:o,elements:s,rects:u,platform:m,strategy:g}=r,{padding:d=2,x:p,y:h}=e,y=a(m.convertOffsetParentRelativeRectToViewportRelativeRect?await m.convertOffsetParentRelativeRectToViewportRelativeRect({rect:u.reference,offsetParent:await(null==m.getOffsetParent?void 0:m.getOffsetParent(s.floating)),strategy:g}):u.reference),x=null!=(i=await(null==m.getClientRects?void 0:m.getClientRects(s.reference)))?i:[],w=l(d);const v=await m.getElementRects({reference:{getBoundingClientRect:function(){var e;if(2===x.length&&x[0].left>x[1].right&&null!=p&&null!=h)return null!=(e=x.find((t=>p>t.left-w.left&&p<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)))?e:y;if(x.length>=2){if("x"===n(o)){const e=x[0],n=x[x.length-1],r="top"===t(o),i=e.top,l=n.bottom,a=r?e.left:n.left,s=r?e.right:n.right;return{top:i,bottom:l,left:a,right:s,width:s-a,height:l-i,x:a,y:i}}const e="left"===t(o),r=f(...x.map((t=>t.right))),i=c(...x.map((t=>t.left))),l=x.filter((t=>e?t.left===i:t.right===r)),a=l[0].top,s=l[l.length-1].bottom;return{top:a,bottom:s,left:i,right:r,width:r-i,height:s-a,x:i,y:a}}return y}},floating:s.floating,strategy:g});return u.reference.x!==v.reference.x||u.reference.y!==v.reference.y||u.reference.width!==v.reference.width||u.reference.height!==v.reference.height?{reset:{rects:v}}:{}}}};export{m as arrow,v as autoPlacement,o as computePosition,s as detectOverflow,b as flip,P as hide,E as inline,L as limitShift,T as offset,a as rectToClientRect,D as shift,k as size};
function t(t){return t.split("-")[0]}function e(t){return t.split("-")[1]}function n(e){return["top","bottom"].includes(t(e))?"x":"y"}function r(t){return"y"===t?"height":"width"}function i(i,o,a){let{reference:l,floating:s}=i;const c=l.x+l.width/2-s.width/2,f=l.y+l.height/2-s.height/2,u=n(o),m=r(u),g=l[m]/2-s[m]/2,d="x"===u;let p;switch(t(o)){case"top":p={x:c,y:l.y-s.height};break;case"bottom":p={x:c,y:l.y+l.height};break;case"right":p={x:l.x+l.width,y:f};break;case"left":p={x:l.x-s.width,y:f};break;default:p={x:l.x,y:l.y}}switch(e(o)){case"start":p[u]-=g*(a&&d?-1:1);break;case"end":p[u]+=g*(a&&d?-1:1)}return p}const o=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n,s=await(null==l.isRTL?void 0:l.isRTL(e));let c=await l.getElementRects({reference:t,floating:e,strategy:o}),{x:f,y:u}=i(c,r,s),m=r,g={};for(let n=0;n<a.length;n++){const{name:d,fn:p}=a[n],{x:h,y:y,data:x,reset:w}=await p({x:f,y:u,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:c,platform:l,elements:{reference:t,floating:e}});f=null!=h?h:f,u=null!=y?y:u,g={...g,[d]:{...g[d],...x}},w&&("object"==typeof w&&(w.placement&&(m=w.placement),w.rects&&(c=!0===w.rects?await l.getElementRects({reference:t,floating:e,strategy:o}):w.rects),({x:f,y:u}=i(c,m,s))),n=-1)}return{x:f,y:u,placement:m,strategy:o,middlewareData:g}};function a(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function l(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function s(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:o,rects:s,elements:c,strategy:f}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:g="floating",altBoundary:d=!1,padding:p=0}=e,h=a(p),y=c[d?"floating"===g?"reference":"floating":g],x=l(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(y)))||n?y:y.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(c.floating)),boundary:u,rootBoundary:m,strategy:f})),w=l(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===g?{...s.floating,x:r,y:i}:s.reference,offsetParent:await(null==o.getOffsetParent?void 0:o.getOffsetParent(c.floating)),strategy:f}):s[g]);return{top:x.top-w.top+h.top,bottom:w.bottom-x.bottom+h.bottom,left:x.left-w.left+h.left,right:w.right-x.right+h.right}}const c=Math.min,f=Math.max;function u(t,e,n){return f(t,c(e,n))}const m=t=>({name:"arrow",options:t,async fn(e){const{element:i,padding:o=0}=null!=t?t:{},{x:l,y:s,placement:c,rects:f,platform:m}=e;if(null==i)return{};const g=a(o),d={x:l,y:s},p=n(c),h=r(p),y=await m.getDimensions(i),x="y"===p?"top":"left",w="y"===p?"bottom":"right",v=f.reference[h]+f.reference[p]-d[p]-f.floating[h],b=d[p]-f.reference[p],R=await(null==m.getOffsetParent?void 0:m.getOffsetParent(i)),A=R?"y"===p?R.clientHeight||0:R.clientWidth||0:0,P=v/2-b/2,T=g[x],O=A-y[h]-g[w],D=A/2-y[h]/2+P,L=u(T,D,O);return{data:{[p]:L,centerOffset:D-L}}}}),g={left:"right",right:"left",bottom:"top",top:"bottom"};function d(t){return t.replace(/left|right|bottom|top/g,(t=>g[t]))}function p(t,i,o){void 0===o&&(o=!1);const a=e(t),l=n(t),s=r(l);let c="x"===l?a===(o?"end":"start")?"right":"left":"start"===a?"bottom":"top";return i.reference[s]>i.floating[s]&&(c=d(c)),{main:c,cross:d(c)}}const h={start:"end",end:"start"};function y(t){return t.replace(/start|end/g,(t=>h[t]))}const x=["top","right","bottom","left"],w=x.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);const v=function(n){return void 0===n&&(n={}),{name:"autoPlacement",options:n,async fn(r){var i,o,a,l,c;const{x:f,y:u,rects:m,middlewareData:g,placement:d,platform:h,elements:x}=r,{alignment:v=null,allowedPlacements:b=w,autoAlignment:R=!0,...A}=n,P=function(n,r,i){return(n?[...i.filter((t=>e(t)===n)),...i.filter((t=>e(t)!==n))]:i.filter((e=>t(e)===e))).filter((t=>!n||e(t)===n||!!r&&y(t)!==t))}(v,R,b),T=await s(r,A),O=null!=(i=null==(o=g.autoPlacement)?void 0:o.index)?i:0,D=P[O];if(null==D)return{};const{main:L,cross:k}=p(D,m,await(null==h.isRTL?void 0:h.isRTL(x.floating)));if(d!==D)return{x:f,y:u,reset:{placement:P[0]}};const E=[T[t(D)],T[L],T[k]],C=[...null!=(a=null==(l=g.autoPlacement)?void 0:l.overflows)?a:[],{placement:D,overflows:E}],B=P[O+1];if(B)return{data:{index:O+1,overflows:C},reset:{placement:B}};const H=C.slice().sort(((t,e)=>t.overflows[0]-e.overflows[0])),V=null==(c=H.find((t=>{let{overflows:e}=t;return e.every((t=>t<=0))})))?void 0:c.placement,F=null!=V?V:H[0].placement;return F!==d?{data:{index:O+1,overflows:C},reset:{placement:F}}:{}}}};const b=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(n){var r;const{placement:i,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:f}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:h="bestFit",flipAlignment:x=!0,...w}=e,v=t(i),b=g||(v===l||!x?[d(l)]:function(t){const e=d(t);return[y(t),e,y(e)]}(l)),R=[l,...b],A=await s(n,w),P=[];let T=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&P.push(A[v]),m){const{main:t,cross:e}=p(i,a,await(null==c.isRTL?void 0:c.isRTL(f.floating)));P.push(A[t],A[e])}if(T=[...T,{placement:i,overflows:P}],!P.every((t=>t<=0))){var O,D;const t=(null!=(O=null==(D=o.flip)?void 0:D.index)?O:0)+1,e=R[t];if(e)return{data:{index:t,overflows:T},reset:{placement:e}};let n="bottom";switch(h){case"bestFit":{var L;const t=null==(L=T.slice().sort(((t,e)=>t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)-e.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)))[0])?void 0:L.placement;t&&(n=t);break}case"initialPlacement":n=l}if(i!==n)return{reset:{placement:n}}}return{}}}};function R(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function A(t){return x.some((e=>t[e]>=0))}const P=function(t){let{strategy:e="referenceHidden",...n}=void 0===t?{}:t;return{name:"hide",async fn(t){const{rects:r}=t;switch(e){case"referenceHidden":{const e=R(await s(t,{...n,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:A(e)}}}case"escaped":{const e=R(await s(t,{...n,altBoundary:!0}),r.floating);return{data:{escapedOffsets:e,escaped:A(e)}}}default:return{}}}}};const T=function(r){return void 0===r&&(r=0),{name:"offset",options:r,async fn(i){const{x:o,y:a,placement:l,rects:s,platform:c,elements:f}=i,u=function(r,i,o,a){void 0===a&&(a=!1);const l=t(r),s=e(r),c="x"===n(r),f=["left","top"].includes(l)?-1:1,u=a&&c?-1:1,m="function"==typeof o?o({...i,placement:r}):o,g="number"==typeof m;let{mainAxis:d,crossAxis:p,alignmentAxis:h}=g?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...m};return s&&"number"==typeof h&&(p="end"===s?-1*h:h),c?{x:p*u,y:d*f}:{x:d*f,y:p*u}}(l,s,r,await(null==c.isRTL?void 0:c.isRTL(f.floating)));return{x:o+u.x,y:a+u.y,data:u}}}};function O(t){return"x"===t?"y":"x"}const D=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(r){const{x:i,y:o,placement:a}=r,{mainAxis:l=!0,crossAxis:c=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=e,g={x:i,y:o},d=await s(r,m),p=n(t(a)),h=O(p);let y=g[p],x=g[h];if(l){const t="y"===p?"bottom":"right";y=u(y+d["y"===p?"top":"left"],y,y-d[t])}if(c){const t="y"===h?"bottom":"right";x=u(x+d["y"===h?"top":"left"],x,x-d[t])}const w=f.fn({...r,[p]:y,[h]:x});return{...w,data:{x:w.x-i,y:w.y-o}}}}},L=function(e){return void 0===e&&(e={}),{options:e,fn(r){const{x:i,y:o,placement:a,rects:l,middlewareData:s}=r,{offset:c=0,mainAxis:f=!0,crossAxis:u=!0}=e,m={x:i,y:o},g=n(a),d=O(g);let p=m[g],h=m[d];const y="function"==typeof c?c({...l,placement:a}):c,x="number"==typeof y?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(f){const t="y"===g?"height":"width",e=l.reference[g]-l.floating[t]+x.mainAxis,n=l.reference[g]+l.reference[t]-x.mainAxis;p<e?p=e:p>n&&(p=n)}if(u){var w,v,b,R;const e="y"===g?"width":"height",n=["top","left"].includes(t(a)),r=l.reference[d]-l.floating[e]+(n&&null!=(w=null==(v=s.offset)?void 0:v[d])?w:0)+(n?0:x.crossAxis),i=l.reference[d]+l.reference[e]+(n?0:null!=(b=null==(R=s.offset)?void 0:R[d])?b:0)-(n?x.crossAxis:0);h<r?h=r:h>i&&(h=i)}return{[g]:p,[d]:h}}}},k=function(n){return void 0===n&&(n={}),{name:"size",options:n,async fn(r){const{placement:i,rects:o,platform:a,elements:l}=r,{apply:c,...u}=n,m=await s(r,u),g=t(i),d=e(i);let p,h;"top"===g||"bottom"===g?(p=g,h=d===(await(null==a.isRTL?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(h=g,p="end"===d?"top":"bottom");const y=f(m.left,0),x=f(m.right,0),w=f(m.top,0),v=f(m.bottom,0),b={height:o.floating.height-(["left","right"].includes(i)?2*(0!==w||0!==v?w+v:f(m.top,m.bottom)):m[p]),width:o.floating.width-(["top","bottom"].includes(i)?2*(0!==y||0!==x?y+x:f(m.left,m.right)):m[h])},R=await a.getDimensions(l.floating);null==c||c({...b,...o});const A=await a.getDimensions(l.floating);return R.width!==A.width||R.height!==A.height?{reset:{rects:!0}}:{}}}},E=function(e){return void 0===e&&(e={}),{name:"inline",options:e,async fn(r){var i;const{placement:o,elements:s,rects:u,platform:m,strategy:g}=r,{padding:d=2,x:p,y:h}=e,y=l(m.convertOffsetParentRelativeRectToViewportRelativeRect?await m.convertOffsetParentRelativeRectToViewportRelativeRect({rect:u.reference,offsetParent:await(null==m.getOffsetParent?void 0:m.getOffsetParent(s.floating)),strategy:g}):u.reference),x=null!=(i=await(null==m.getClientRects?void 0:m.getClientRects(s.reference)))?i:[],w=a(d);const v=await m.getElementRects({reference:{getBoundingClientRect:function(){var e;if(2===x.length&&x[0].left>x[1].right&&null!=p&&null!=h)return null!=(e=x.find((t=>p>t.left-w.left&&p<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)))?e:y;if(x.length>=2){if("x"===n(o)){const e=x[0],n=x[x.length-1],r="top"===t(o),i=e.top,a=n.bottom,l=r?e.left:n.left,s=r?e.right:n.right;return{top:i,bottom:a,left:l,right:s,width:s-l,height:a-i,x:l,y:i}}const e="left"===t(o),r=f(...x.map((t=>t.right))),i=c(...x.map((t=>t.left))),a=x.filter((t=>e?t.left===i:t.right===r)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:r,width:r-i,height:s-l,x:i,y:l}}return y}},floating:s.floating,strategy:g});return u.reference.x!==v.reference.x||u.reference.y!==v.reference.y||u.reference.width!==v.reference.width||u.reference.height!==v.reference.height?{reset:{rects:v}}:{}}}};export{m as arrow,v as autoPlacement,o as computePosition,s as detectOverflow,b as flip,P as hide,E as inline,L as limitShift,T as offset,l as rectToClientRect,D as shift,k as size};

@@ -269,3 +269,4 @@ (function (global, factory) {

boundary,
rootBoundary
rootBoundary,
strategy
}));

@@ -272,0 +273,0 @@ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";function e(t){return t.split("-")[0]}function n(t){return t.split("-")[1]}function i(t){return["top","bottom"].includes(e(t))?"x":"y"}function o(t){return"y"===t?"height":"width"}function r(t,r,l){let{reference:a,floating:s}=t;const f=a.x+a.width/2-s.width/2,c=a.y+a.height/2-s.height/2,u=i(r),m=o(u),d=a[m]/2-s[m]/2,g="x"===u;let p;switch(e(r)){case"top":p={x:f,y:a.y-s.height};break;case"bottom":p={x:f,y:a.y+a.height};break;case"right":p={x:a.x+a.width,y:c};break;case"left":p={x:a.x-s.width,y:c};break;default:p={x:a.x,y:a.y}}switch(n(r)){case"start":p[u]-=d*(l&&g?-1:1);break;case"end":p[u]+=d*(l&&g?-1:1)}return p}function l(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function a(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function s(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:s,elements:f,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:g=!1,padding:p=0}=e,h=l(p),y=f[g?"floating"===d?"reference":"floating":d],x=a(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(y)))||n?y:y.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(f.floating)),boundary:u,rootBoundary:m})),w=a(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===d?{...s.floating,x:i,y:o}:s.reference,offsetParent:await(null==r.getOffsetParent?void 0:r.getOffsetParent(f.floating)),strategy:c}):s[d]);return{top:x.top-w.top+h.top,bottom:w.bottom-x.bottom+h.bottom,left:x.left-w.left+h.left,right:w.right-x.right+h.right}}const f=Math.min,c=Math.max;function u(t,e,n){return c(t,f(e,n))}const m={left:"right",right:"left",bottom:"top",top:"bottom"};function d(t){return t.replace(/left|right|bottom|top/g,(t=>m[t]))}function g(t,e,r){void 0===r&&(r=!1);const l=n(t),a=i(t),s=o(a);let f="x"===a?l===(r?"end":"start")?"right":"left":"start"===l?"bottom":"top";return e.reference[s]>e.floating[s]&&(f=d(f)),{main:f,cross:d(f)}}const p={start:"end",end:"start"};function h(t){return t.replace(/start|end/g,(t=>p[t]))}const y=["top","right","bottom","left"],x=y.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);function w(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function v(t){return y.some((e=>t[e]>=0))}function b(t){return"x"===t?"y":"x"}t.arrow=t=>({name:"arrow",options:t,async fn(e){const{element:n,padding:r=0}=null!=t?t:{},{x:a,y:s,placement:f,rects:c,platform:m}=e;if(null==n)return{};const d=l(r),g={x:a,y:s},p=i(f),h=o(p),y=await m.getDimensions(n),x="y"===p?"top":"left",w="y"===p?"bottom":"right",v=c.reference[h]+c.reference[p]-g[p]-c.floating[h],b=g[p]-c.reference[p],R=await(null==m.getOffsetParent?void 0:m.getOffsetParent(n)),A=R?"y"===p?R.clientHeight||0:R.clientWidth||0:0,P=v/2-b/2,T=d[x],O=A-y[h]-d[w],D=A/2-y[h]/2+P,L=u(T,D,O);return{data:{[p]:L,centerOffset:D-L}}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(i){var o,r,l,a,f;const{x:c,y:u,rects:m,middlewareData:d,placement:p,platform:y,elements:w}=i,{alignment:v=null,allowedPlacements:b=x,autoAlignment:R=!0,...A}=t,P=function(t,i,o){return(t?[...o.filter((e=>n(e)===t)),...o.filter((e=>n(e)!==t))]:o.filter((t=>e(t)===t))).filter((e=>!t||n(e)===t||!!i&&h(e)!==e))}(v,R,b),T=await s(i,A),O=null!=(o=null==(r=d.autoPlacement)?void 0:r.index)?o:0,D=P[O];if(null==D)return{};const{main:L,cross:k}=g(D,m,await(null==y.isRTL?void 0:y.isRTL(w.floating)));if(p!==D)return{x:c,y:u,reset:{placement:P[0]}};const C=[T[e(D)],T[L],T[k]],E=[...null!=(l=null==(a=d.autoPlacement)?void 0:a.overflows)?l:[],{placement:D,overflows:C}],B=P[O+1];if(B)return{data:{index:O+1,overflows:E},reset:{placement:B}};const H=E.slice().sort(((t,e)=>t.overflows[0]-e.overflows[0])),V=null==(f=H.find((t=>{let{overflows:e}=t;return e.every((t=>t<=0))})))?void 0:f.placement,j=null!=V?V:H[0].placement;return j!==p?{data:{index:O+1,overflows:E},reset:{placement:j}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:l=[],platform:a}=n,s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:u}=r(f,i,s),m=i,d={};for(let n=0;n<l.length;n++){const{name:g,fn:p}=l[n],{x:h,y:y,data:x,reset:w}=await p({x:c,y:u,initialPlacement:i,placement:m,strategy:o,middlewareData:d,rects:f,platform:a,elements:{reference:t,floating:e}});c=null!=h?h:c,u=null!=y?y:u,d={...d,[g]:{...d[g],...x}},w&&("object"==typeof w&&(w.placement&&(m=w.placement),w.rects&&(f=!0===w.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):w.rects),({x:c,y:u}=r(f,m,s))),n=-1)}return{x:c,y:u,placement:m,strategy:o,middlewareData:d}},t.detectOverflow=s,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var i;const{placement:o,middlewareData:r,rects:l,initialPlacement:a,platform:f,elements:c}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:y="bestFit",flipAlignment:x=!0,...w}=t,v=e(o),b=p||(v===a||!x?[d(a)]:function(t){const e=d(t);return[h(t),e,h(e)]}(a)),R=[a,...b],A=await s(n,w),P=[];let T=(null==(i=r.flip)?void 0:i.overflows)||[];if(u&&P.push(A[v]),m){const{main:t,cross:e}=g(o,l,await(null==f.isRTL?void 0:f.isRTL(c.floating)));P.push(A[t],A[e])}if(T=[...T,{placement:o,overflows:P}],!P.every((t=>t<=0))){var O,D;const t=(null!=(O=null==(D=r.flip)?void 0:D.index)?O:0)+1,e=R[t];if(e)return{data:{index:t,overflows:T},reset:{placement:e}};let n="bottom";switch(y){case"bestFit":{var L;const t=null==(L=T.slice().sort(((t,e)=>t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)-e.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)))[0])?void 0:L.placement;t&&(n=t);break}case"initialPlacement":n=a}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){let{strategy:e="referenceHidden",...n}=void 0===t?{}:t;return{name:"hide",async fn(t){const{rects:i}=t;switch(e){case"referenceHidden":{const e=w(await s(t,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:v(e)}}}case"escaped":{const e=w(await s(t,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:e,escaped:v(e)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(n){var o;const{placement:r,elements:s,rects:u,platform:m,strategy:d}=n,{padding:g=2,x:p,y:h}=t,y=a(m.convertOffsetParentRelativeRectToViewportRelativeRect?await m.convertOffsetParentRelativeRectToViewportRelativeRect({rect:u.reference,offsetParent:await(null==m.getOffsetParent?void 0:m.getOffsetParent(s.floating)),strategy:d}):u.reference),x=null!=(o=await(null==m.getClientRects?void 0:m.getClientRects(s.reference)))?o:[],w=l(g);const v=await m.getElementRects({reference:{getBoundingClientRect:function(){var t;if(2===x.length&&x[0].left>x[1].right&&null!=p&&null!=h)return null!=(t=x.find((t=>p>t.left-w.left&&p<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)))?t:y;if(x.length>=2){if("x"===i(r)){const t=x[0],n=x[x.length-1],i="top"===e(r),o=t.top,l=n.bottom,a=i?t.left:n.left,s=i?t.right:n.right;return{top:o,bottom:l,left:a,right:s,width:s-a,height:l-o,x:a,y:o}}const t="left"===e(r),n=c(...x.map((t=>t.right))),o=f(...x.map((t=>t.left))),l=x.filter((e=>t?e.left===o:e.right===n)),a=l[0].top,s=l[l.length-1].bottom;return{top:a,bottom:s,left:o,right:n,width:n-o,height:s-a,x:o,y:a}}return y}},floating:s.floating,strategy:d});return u.reference.x!==v.reference.x||u.reference.y!==v.reference.y||u.reference.width!==v.reference.width||u.reference.height!==v.reference.height?{reset:{rects:v}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(n){const{x:o,y:r,placement:l,rects:a,middlewareData:s}=n,{offset:f=0,mainAxis:c=!0,crossAxis:u=!0}=t,m={x:o,y:r},d=i(l),g=b(d);let p=m[d],h=m[g];const y="function"==typeof f?f({...a,placement:l}):f,x="number"==typeof y?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const t="y"===d?"height":"width",e=a.reference[d]-a.floating[t]+x.mainAxis,n=a.reference[d]+a.reference[t]-x.mainAxis;p<e?p=e:p>n&&(p=n)}if(u){var w,v,R,A;const t="y"===d?"width":"height",n=["top","left"].includes(e(l)),i=a.reference[g]-a.floating[t]+(n&&null!=(w=null==(v=s.offset)?void 0:v[g])?w:0)+(n?0:x.crossAxis),o=a.reference[g]+a.reference[t]+(n?0:null!=(R=null==(A=s.offset)?void 0:A[g])?R:0)-(n?x.crossAxis:0);h<i?h=i:h>o&&(h=o)}return{[d]:p,[g]:h}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(o){const{x:r,y:l,placement:a,rects:s,platform:f,elements:c}=o,u=function(t,o,r,l){void 0===l&&(l=!1);const a=e(t),s=n(t),f="x"===i(t),c=["left","top"].includes(a)?-1:1,u=l&&f?-1:1,m="function"==typeof r?r({...o,placement:t}):r,d="number"==typeof m;let{mainAxis:g,crossAxis:p,alignmentAxis:h}=d?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...m};return s&&"number"==typeof h&&(p="end"===s?-1*h:h),f?{x:p*u,y:g*c}:{x:g*c,y:p*u}}(a,s,t,await(null==f.isRTL?void 0:f.isRTL(c.floating)));return{x:r+u.x,y:l+u.y,data:u}}}},t.rectToClientRect=a,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(n){const{x:o,y:r,placement:l}=n,{mainAxis:a=!0,crossAxis:f=!1,limiter:c={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=t,d={x:o,y:r},g=await s(n,m),p=i(e(l)),h=b(p);let y=d[p],x=d[h];if(a){const t="y"===p?"bottom":"right";y=u(y+g["y"===p?"top":"left"],y,y-g[t])}if(f){const t="y"===h?"bottom":"right";x=u(x+g["y"===h?"top":"left"],x,x-g[t])}const w=c.fn({...n,[p]:y,[h]:x});return{...w,data:{x:w.x-o,y:w.y-r}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(i){const{placement:o,rects:r,platform:l,elements:a}=i,{apply:f,...u}=t,m=await s(i,u),d=e(o),g=n(o);let p,h;"top"===d||"bottom"===d?(p=d,h=g===(await(null==l.isRTL?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(h=d,p="end"===g?"top":"bottom");const y=c(m.left,0),x=c(m.right,0),w=c(m.top,0),v=c(m.bottom,0),b={height:r.floating.height-(["left","right"].includes(o)?2*(0!==w||0!==v?w+v:c(m.top,m.bottom)):m[p]),width:r.floating.width-(["top","bottom"].includes(o)?2*(0!==y||0!==x?y+x:c(m.left,m.right)):m[h])},R=await l.getDimensions(a.floating);null==f||f({...b,...r});const A=await l.getDimensions(a.floating);return R.width!==A.width||R.height!==A.height?{reset:{rects:!0}}:{}}}},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";function e(t){return t.split("-")[0]}function n(t){return t.split("-")[1]}function i(t){return["top","bottom"].includes(e(t))?"x":"y"}function o(t){return"y"===t?"height":"width"}function r(t,r,l){let{reference:a,floating:s}=t;const f=a.x+a.width/2-s.width/2,c=a.y+a.height/2-s.height/2,u=i(r),m=o(u),d=a[m]/2-s[m]/2,g="x"===u;let p;switch(e(r)){case"top":p={x:f,y:a.y-s.height};break;case"bottom":p={x:f,y:a.y+a.height};break;case"right":p={x:a.x+a.width,y:c};break;case"left":p={x:a.x-s.width,y:c};break;default:p={x:a.x,y:a.y}}switch(n(r)){case"start":p[u]-=d*(l&&g?-1:1);break;case"end":p[u]+=d*(l&&g?-1:1)}return p}function l(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function a(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function s(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:s,elements:f,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:g=!1,padding:p=0}=e,h=l(p),y=f[g?"floating"===d?"reference":"floating":d],x=a(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(y)))||n?y:y.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(f.floating)),boundary:u,rootBoundary:m,strategy:c})),w=a(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===d?{...s.floating,x:i,y:o}:s.reference,offsetParent:await(null==r.getOffsetParent?void 0:r.getOffsetParent(f.floating)),strategy:c}):s[d]);return{top:x.top-w.top+h.top,bottom:w.bottom-x.bottom+h.bottom,left:x.left-w.left+h.left,right:w.right-x.right+h.right}}const f=Math.min,c=Math.max;function u(t,e,n){return c(t,f(e,n))}const m={left:"right",right:"left",bottom:"top",top:"bottom"};function d(t){return t.replace(/left|right|bottom|top/g,(t=>m[t]))}function g(t,e,r){void 0===r&&(r=!1);const l=n(t),a=i(t),s=o(a);let f="x"===a?l===(r?"end":"start")?"right":"left":"start"===l?"bottom":"top";return e.reference[s]>e.floating[s]&&(f=d(f)),{main:f,cross:d(f)}}const p={start:"end",end:"start"};function h(t){return t.replace(/start|end/g,(t=>p[t]))}const y=["top","right","bottom","left"],x=y.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);function w(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function v(t){return y.some((e=>t[e]>=0))}function b(t){return"x"===t?"y":"x"}t.arrow=t=>({name:"arrow",options:t,async fn(e){const{element:n,padding:r=0}=null!=t?t:{},{x:a,y:s,placement:f,rects:c,platform:m}=e;if(null==n)return{};const d=l(r),g={x:a,y:s},p=i(f),h=o(p),y=await m.getDimensions(n),x="y"===p?"top":"left",w="y"===p?"bottom":"right",v=c.reference[h]+c.reference[p]-g[p]-c.floating[h],b=g[p]-c.reference[p],R=await(null==m.getOffsetParent?void 0:m.getOffsetParent(n)),A=R?"y"===p?R.clientHeight||0:R.clientWidth||0:0,P=v/2-b/2,T=d[x],O=A-y[h]-d[w],D=A/2-y[h]/2+P,L=u(T,D,O);return{data:{[p]:L,centerOffset:D-L}}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(i){var o,r,l,a,f;const{x:c,y:u,rects:m,middlewareData:d,placement:p,platform:y,elements:w}=i,{alignment:v=null,allowedPlacements:b=x,autoAlignment:R=!0,...A}=t,P=function(t,i,o){return(t?[...o.filter((e=>n(e)===t)),...o.filter((e=>n(e)!==t))]:o.filter((t=>e(t)===t))).filter((e=>!t||n(e)===t||!!i&&h(e)!==e))}(v,R,b),T=await s(i,A),O=null!=(o=null==(r=d.autoPlacement)?void 0:r.index)?o:0,D=P[O];if(null==D)return{};const{main:L,cross:k}=g(D,m,await(null==y.isRTL?void 0:y.isRTL(w.floating)));if(p!==D)return{x:c,y:u,reset:{placement:P[0]}};const C=[T[e(D)],T[L],T[k]],E=[...null!=(l=null==(a=d.autoPlacement)?void 0:a.overflows)?l:[],{placement:D,overflows:C}],B=P[O+1];if(B)return{data:{index:O+1,overflows:E},reset:{placement:B}};const H=E.slice().sort(((t,e)=>t.overflows[0]-e.overflows[0])),V=null==(f=H.find((t=>{let{overflows:e}=t;return e.every((t=>t<=0))})))?void 0:f.placement,j=null!=V?V:H[0].placement;return j!==p?{data:{index:O+1,overflows:E},reset:{placement:j}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:l=[],platform:a}=n,s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:u}=r(f,i,s),m=i,d={};for(let n=0;n<l.length;n++){const{name:g,fn:p}=l[n],{x:h,y:y,data:x,reset:w}=await p({x:c,y:u,initialPlacement:i,placement:m,strategy:o,middlewareData:d,rects:f,platform:a,elements:{reference:t,floating:e}});c=null!=h?h:c,u=null!=y?y:u,d={...d,[g]:{...d[g],...x}},w&&("object"==typeof w&&(w.placement&&(m=w.placement),w.rects&&(f=!0===w.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):w.rects),({x:c,y:u}=r(f,m,s))),n=-1)}return{x:c,y:u,placement:m,strategy:o,middlewareData:d}},t.detectOverflow=s,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var i;const{placement:o,middlewareData:r,rects:l,initialPlacement:a,platform:f,elements:c}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:y="bestFit",flipAlignment:x=!0,...w}=t,v=e(o),b=p||(v===a||!x?[d(a)]:function(t){const e=d(t);return[h(t),e,h(e)]}(a)),R=[a,...b],A=await s(n,w),P=[];let T=(null==(i=r.flip)?void 0:i.overflows)||[];if(u&&P.push(A[v]),m){const{main:t,cross:e}=g(o,l,await(null==f.isRTL?void 0:f.isRTL(c.floating)));P.push(A[t],A[e])}if(T=[...T,{placement:o,overflows:P}],!P.every((t=>t<=0))){var O,D;const t=(null!=(O=null==(D=r.flip)?void 0:D.index)?O:0)+1,e=R[t];if(e)return{data:{index:t,overflows:T},reset:{placement:e}};let n="bottom";switch(y){case"bestFit":{var L;const t=null==(L=T.slice().sort(((t,e)=>t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)-e.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)))[0])?void 0:L.placement;t&&(n=t);break}case"initialPlacement":n=a}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){let{strategy:e="referenceHidden",...n}=void 0===t?{}:t;return{name:"hide",async fn(t){const{rects:i}=t;switch(e){case"referenceHidden":{const e=w(await s(t,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:v(e)}}}case"escaped":{const e=w(await s(t,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:e,escaped:v(e)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(n){var o;const{placement:r,elements:s,rects:u,platform:m,strategy:d}=n,{padding:g=2,x:p,y:h}=t,y=a(m.convertOffsetParentRelativeRectToViewportRelativeRect?await m.convertOffsetParentRelativeRectToViewportRelativeRect({rect:u.reference,offsetParent:await(null==m.getOffsetParent?void 0:m.getOffsetParent(s.floating)),strategy:d}):u.reference),x=null!=(o=await(null==m.getClientRects?void 0:m.getClientRects(s.reference)))?o:[],w=l(g);const v=await m.getElementRects({reference:{getBoundingClientRect:function(){var t;if(2===x.length&&x[0].left>x[1].right&&null!=p&&null!=h)return null!=(t=x.find((t=>p>t.left-w.left&&p<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)))?t:y;if(x.length>=2){if("x"===i(r)){const t=x[0],n=x[x.length-1],i="top"===e(r),o=t.top,l=n.bottom,a=i?t.left:n.left,s=i?t.right:n.right;return{top:o,bottom:l,left:a,right:s,width:s-a,height:l-o,x:a,y:o}}const t="left"===e(r),n=c(...x.map((t=>t.right))),o=f(...x.map((t=>t.left))),l=x.filter((e=>t?e.left===o:e.right===n)),a=l[0].top,s=l[l.length-1].bottom;return{top:a,bottom:s,left:o,right:n,width:n-o,height:s-a,x:o,y:a}}return y}},floating:s.floating,strategy:d});return u.reference.x!==v.reference.x||u.reference.y!==v.reference.y||u.reference.width!==v.reference.width||u.reference.height!==v.reference.height?{reset:{rects:v}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(n){const{x:o,y:r,placement:l,rects:a,middlewareData:s}=n,{offset:f=0,mainAxis:c=!0,crossAxis:u=!0}=t,m={x:o,y:r},d=i(l),g=b(d);let p=m[d],h=m[g];const y="function"==typeof f?f({...a,placement:l}):f,x="number"==typeof y?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const t="y"===d?"height":"width",e=a.reference[d]-a.floating[t]+x.mainAxis,n=a.reference[d]+a.reference[t]-x.mainAxis;p<e?p=e:p>n&&(p=n)}if(u){var w,v,R,A;const t="y"===d?"width":"height",n=["top","left"].includes(e(l)),i=a.reference[g]-a.floating[t]+(n&&null!=(w=null==(v=s.offset)?void 0:v[g])?w:0)+(n?0:x.crossAxis),o=a.reference[g]+a.reference[t]+(n?0:null!=(R=null==(A=s.offset)?void 0:A[g])?R:0)-(n?x.crossAxis:0);h<i?h=i:h>o&&(h=o)}return{[d]:p,[g]:h}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(o){const{x:r,y:l,placement:a,rects:s,platform:f,elements:c}=o,u=function(t,o,r,l){void 0===l&&(l=!1);const a=e(t),s=n(t),f="x"===i(t),c=["left","top"].includes(a)?-1:1,u=l&&f?-1:1,m="function"==typeof r?r({...o,placement:t}):r,d="number"==typeof m;let{mainAxis:g,crossAxis:p,alignmentAxis:h}=d?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...m};return s&&"number"==typeof h&&(p="end"===s?-1*h:h),f?{x:p*u,y:g*c}:{x:g*c,y:p*u}}(a,s,t,await(null==f.isRTL?void 0:f.isRTL(c.floating)));return{x:r+u.x,y:l+u.y,data:u}}}},t.rectToClientRect=a,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(n){const{x:o,y:r,placement:l}=n,{mainAxis:a=!0,crossAxis:f=!1,limiter:c={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=t,d={x:o,y:r},g=await s(n,m),p=i(e(l)),h=b(p);let y=d[p],x=d[h];if(a){const t="y"===p?"bottom":"right";y=u(y+g["y"===p?"top":"left"],y,y-g[t])}if(f){const t="y"===h?"bottom":"right";x=u(x+g["y"===h?"top":"left"],x,x-g[t])}const w=c.fn({...n,[p]:y,[h]:x});return{...w,data:{x:w.x-o,y:w.y-r}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(i){const{placement:o,rects:r,platform:l,elements:a}=i,{apply:f,...u}=t,m=await s(i,u),d=e(o),g=n(o);let p,h;"top"===d||"bottom"===d?(p=d,h=g===(await(null==l.isRTL?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(h=d,p="end"===g?"top":"bottom");const y=c(m.left,0),x=c(m.right,0),w=c(m.top,0),v=c(m.bottom,0),b={height:r.floating.height-(["left","right"].includes(o)?2*(0!==w||0!==v?w+v:c(m.top,m.bottom)):m[p]),width:r.floating.width-(["top","bottom"].includes(o)?2*(0!==y||0!==x?y+x:c(m.left,m.right)):m[h])},R=await l.getDimensions(a.floating);null==f||f({...b,...r});const A=await l.getDimensions(a.floating);return R.width!==A.width||R.height!==A.height?{reset:{rects:!0}}:{}}}},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@floating-ui/core",
"version": "0.6.0",
"version": "0.6.1",
"@rollingversions": {

@@ -5,0 +5,0 @@ "baseVersion": [

@@ -23,2 +23,3 @@ export declare type Alignment = 'start' | 'end';

rootBoundary: RootBoundary;
strategy: Strategy;
}) => Promisable<Rect>;

@@ -25,0 +26,0 @@ getDimensions: (element: any) => Promisable<Dimensions>;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc