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.5.0 to 0.5.1

45

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

@@ -17,8 +17,6 @@ function getSide(placement) {

function computeCoordsFromPlacement(_ref) {
function computeCoordsFromPlacement(_ref, placement, rtl) {
let {
reference,
floating,
placement,
rtl = false
floating
} = _ref;

@@ -98,3 +96,3 @@ const commonX = reference.x + reference.width / 2 - floating.width / 2;

} = config;
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(reference));
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));

@@ -124,6 +122,3 @@ {

y
} = computeCoordsFromPlacement({ ...rects,
placement,
rtl
});
} = computeCoordsFromPlacement(rects, placement, rtl);
let statefulPlacement = placement;

@@ -196,6 +191,3 @@ let middlewareData = {};

y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement,
rtl
}));
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));

@@ -464,3 +456,3 @@ if (reset.skip !== false) {

cross
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))); // Make `computeCoords` start from the right place
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place

@@ -569,3 +561,3 @@ if (placement !== currentPlacement) {

cross
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference)));
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
overflows.push(overflow[main], overflow[cross]);

@@ -703,9 +695,7 @@ }

function convertValueToCoords(_ref) {
let {
placement,
rects,
value,
rtl = false
} = _ref;
function convertValueToCoords(placement, rects, value, rtl) {
if (rtl === void 0) {
rtl = false;
}
const side = getSide(placement);

@@ -770,8 +760,3 @@ const alignment = getAlignment(placement);

} = middlewareArguments;
const diffCoords = convertValueToCoords({
placement,
rects,
value,
rtl: await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))
});
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
return {

@@ -983,3 +968,3 @@ x: x + diffCoords.x,

heightSide = side;
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))) ? 'start' : 'end') ? 'left' : 'right';
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
} else {

@@ -1048,3 +1033,3 @@ widthSide = side;

}) : rects.reference);
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : []);
const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
const paddingObject = getSideObjectFromPadding(padding);

@@ -1051,0 +1036,0 @@

@@ -17,8 +17,6 @@ function getSide(placement) {

function computeCoordsFromPlacement(_ref) {
function computeCoordsFromPlacement(_ref, placement, rtl) {
let {
reference,
floating,
placement,
rtl = false
floating
} = _ref;

@@ -98,3 +96,3 @@ const commonX = reference.x + reference.width / 2 - floating.width / 2;

} = config;
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(reference));
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));

@@ -124,6 +122,3 @@ if (process.env.NODE_ENV !== "production") {

y
} = computeCoordsFromPlacement({ ...rects,
placement,
rtl
});
} = computeCoordsFromPlacement(rects, placement, rtl);
let statefulPlacement = placement;

@@ -196,6 +191,3 @@ let middlewareData = {};

y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement,
rtl
}));
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));

@@ -464,3 +456,3 @@ if (reset.skip !== false) {

cross
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))); // Make `computeCoords` start from the right place
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place

@@ -569,3 +561,3 @@ if (placement !== currentPlacement) {

cross
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference)));
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
overflows.push(overflow[main], overflow[cross]);

@@ -703,9 +695,7 @@ }

function convertValueToCoords(_ref) {
let {
placement,
rects,
value,
rtl = false
} = _ref;
function convertValueToCoords(placement, rects, value, rtl) {
if (rtl === void 0) {
rtl = false;
}
const side = getSide(placement);

@@ -770,8 +760,3 @@ const alignment = getAlignment(placement);

} = middlewareArguments;
const diffCoords = convertValueToCoords({
placement,
rects,
value,
rtl: await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))
});
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
return {

@@ -983,3 +968,3 @@ x: x + diffCoords.x,

heightSide = side;
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))) ? 'start' : 'end') ? 'left' : 'right';
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
} else {

@@ -1048,3 +1033,3 @@ widthSide = side;

}) : rects.reference);
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : []);
const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
const paddingObject = getSideObjectFromPadding(padding);

@@ -1051,0 +1036,0 @@

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

@@ -23,8 +23,6 @@ (function (global, factory) {

function computeCoordsFromPlacement(_ref) {
function computeCoordsFromPlacement(_ref, placement, rtl) {
let {
reference,
floating,
placement,
rtl = false
floating
} = _ref;

@@ -104,3 +102,3 @@ const commonX = reference.x + reference.width / 2 - floating.width / 2;

} = config;
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(reference));
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));

@@ -130,6 +128,3 @@ if (process.env.NODE_ENV !== "production") {

y
} = computeCoordsFromPlacement({ ...rects,
placement,
rtl
});
} = computeCoordsFromPlacement(rects, placement, rtl);
let statefulPlacement = placement;

@@ -202,6 +197,3 @@ let middlewareData = {};

y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement,
rtl
}));
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));

@@ -470,3 +462,3 @@ if (reset.skip !== false) {

cross
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))); // Make `computeCoords` start from the right place
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place

@@ -575,3 +567,3 @@ if (placement !== currentPlacement) {

cross
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference)));
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
overflows.push(overflow[main], overflow[cross]);

@@ -709,9 +701,7 @@ }

function convertValueToCoords(_ref) {
let {
placement,
rects,
value,
rtl = false
} = _ref;
function convertValueToCoords(placement, rects, value, rtl) {
if (rtl === void 0) {
rtl = false;
}
const side = getSide(placement);

@@ -776,8 +766,3 @@ const alignment = getAlignment(placement);

} = middlewareArguments;
const diffCoords = convertValueToCoords({
placement,
rects,
value,
rtl: await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))
});
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
return {

@@ -989,3 +974,3 @@ x: x + diffCoords.x,

heightSide = side;
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))) ? 'start' : 'end') ? 'left' : 'right';
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
} else {

@@ -1054,3 +1039,3 @@ widthSide = side;

}) : rects.reference);
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : []);
const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
const paddingObject = getSideObjectFromPadding(padding);

@@ -1057,0 +1042,0 @@

@@ -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 r(t){return["top","bottom"].includes(e(t))?"x":"y"}function o(t){return"y"===t?"height":"width"}function i(t){let{reference:i,floating:l,placement:a,rtl:s=!1}=t;const c=i.x+i.width/2-l.width/2,f=i.y+i.height/2-l.height/2,u=r(a),m=o(u),d=i[m]/2-l[m]/2,p="x"===u;let g;switch(e(a)){case"top":g={x:c,y:i.y-l.height};break;case"bottom":g={x:c,y:i.y+i.height};break;case"right":g={x:i.x+i.width,y:f};break;case"left":g={x:i.x-l.width,y:f};break;default:g={x:i.x,y:i.y}}switch(n(a)){case"start":g[u]-=d*(s&&p?-1:1);break;case"end":g[u]+=d*(s&&p?-1:1)}return 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:o,platform:i,rects:s,elements:c,strategy:f}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:p=!1,padding:g=0}=e,h=l(g),y=c[p?"floating"===d?"reference":"floating":d],x=a(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(y)))||n?y:y.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(c.floating)),boundary:u,rootBoundary:m})),w=a(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===d?{...s.floating,x:r,y:o}:s.reference,offsetParent:await(null==i.getOffsetParent?void 0:i.getOffsetParent(c.floating)),strategy:f}):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 c=Math.min,f=Math.max;function u(t,e,n){return f(t,c(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 p(t,e,i){void 0===i&&(i=!1);const l=n(t),a=r(t),s=o(a);let c="x"===a?l===(i?"end":"start")?"right":"left":"start"===l?"bottom":"top";return e.reference[s]>e.floating[s]&&(c=d(c)),{main:c,cross:d(c)}}const g={start:"end",end:"start"};function h(t){return t.replace(/start|end/g,(t=>g[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:i=0}=null!=t?t:{},{x:a,y:s,placement:c,rects:f,platform:m}=e;if(null==n)return{};const d=l(i),p={x:a,y:s},g=r(c),h=o(g),y=await m.getDimensions(n),x="y"===g?"top":"left",w="y"===g?"bottom":"right",v=f.reference[h]+f.reference[g]-p[g]-f.floating[h],b=p[g]-f.reference[g],R=await(null==m.getOffsetParent?void 0:m.getOffsetParent(n)),A=R?"y"===g?R.clientHeight||0:R.clientWidth||0:0,P=v/2-b/2,T=d[x],O=A-y[h]-d[w],k=A/2-y[h]/2+P,L=u(T,k,O);return{data:{[g]:L,centerOffset:k-L}}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(r){var o,i,l,a,c;const{x:f,y:u,rects:m,middlewareData:d,placement:g,platform:y,elements:w}=r,{alignment:v=null,allowedPlacements:b=x,autoAlignment:R=!0,...A}=t,P=function(t,r,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||!!r&&h(e)!==e))}(v,R,b),T=await s(r,A),O=null!=(o=null==(i=d.autoPlacement)?void 0:i.index)?o:0,k=P[O],{main:L,cross:C}=p(k,m,await(null==y.isRTL?void 0:y.isRTL(w.reference)));if(g!==k)return{x:f,y:u,reset:{skip:!1,placement:P[0]}};const D=[T[e(k)],T[L],T[C]],E=[...null!=(l=null==(a=d.autoPlacement)?void 0:a.overflows)?l:[],{placement:k,overflows:D}],B=P[O+1];if(B)return{data:{index:O+1,overflows:E},reset:{skip:!1,placement:B}};const H=E.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;return{reset:{placement:null!=V?V:H[0].placement}}}}},t.computePosition=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(t));let c=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:f,y:u}=i({...c,placement:r,rtl:s}),m=r,d={};const p=new Set;for(let n=0;n<l.length;n++){const{name:g,fn:h}=l[n];if(p.has(g))continue;const{x:y,y:x,data:w,reset:v}=await h({x:f,y:u,initialPlacement:r,placement:m,strategy:o,middlewareData:d,rects:c,platform:a,elements:{reference:t,floating:e}});f=null!=y?y:f,u=null!=x?x:u,d={...d,[g]:{...d[g],...w}},v&&("object"==typeof v&&(v.placement&&(m=v.placement),v.rects&&(c=!0===v.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):v.rects),({x:f,y:u}=i({...c,placement:m,rtl:s})),!1!==v.skip&&p.add(g)),n=-1)}return{x:f,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 r;const{placement:o,middlewareData:i,rects:l,initialPlacement:a,platform:c,elements:f}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",flipAlignment:x=!0,...w}=t,v=e(o),b=g||(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==(r=i.flip)?void 0:r.overflows)||[];if(u&&P.push(A[v]),m){const{main:t,cross:e}=p(o,l,await(null==c.isRTL?void 0:c.isRTL(f.reference)));P.push(A[t],A[e])}if(T=[...T,{placement:o,overflows:P}],!P.every((t=>t<=0))){var O,k;const t=(null!=(O=null==(k=i.flip)?void 0:k.index)?O:0)+1,e=R[t];if(e)return{data:{index:t,overflows:T},reset:{skip:!1,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}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:r}=t;switch(e){case"referenceHidden":{const e=w(await s(t,{...n,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:v(e)}}}case"escaped":{const e=w(await s(t,{...n,altBoundary:!0}),r.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:i,elements:s,rects:u,platform:m,strategy:d}=n,{padding:p=2,x:g,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=Array.from(null!=(o=await(null==m.getClientRects?void 0:m.getClientRects(s.reference)))?o:[]),w=l(p);return{reset:{rects:await m.getElementRects({reference:{getBoundingClientRect:function(){var t;if(2===x.length&&x[0].left>x[1].right&&null!=g&&null!=h)return null!=(t=x.find((t=>g>t.left-w.left&&g<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)))?t:y;if(x.length>=2){if("x"===r(i)){const t=x[0],n=x[x.length-1],r="top"===e(i),o=t.top,l=n.bottom,a=r?t.left:n.left,s=r?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(i),n=f(...x.map((t=>t.right))),o=c(...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})}}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(n){const{x:o,y:i,placement:l,rects:a,middlewareData:s}=n,{offset:c=0,mainAxis:f=!0,crossAxis:u=!0}=t,m={x:o,y:i},d=r(l),p=b(d);let g=m[d],h=m[p];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"===d?"height":"width",e=a.reference[d]-a.floating[t]+x.mainAxis,n=a.reference[d]+a.reference[t]-x.mainAxis;g<e?g=e:g>n&&(g=n)}if(u){var w,v,R,A;const t="y"===d?"width":"height",n=["top","left"].includes(e(l)),r=a.reference[p]-a.floating[t]+(n&&null!=(w=null==(v=s.offset)?void 0:v[p])?w:0)+(n?0:x.crossAxis),o=a.reference[p]+a.reference[t]+(n?0:null!=(R=null==(A=s.offset)?void 0:A[p])?R:0)-(n?x.crossAxis:0);h<r?h=r:h>o&&(h=o)}return{[d]:g,[p]:h}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(o){const{x:i,y:l,placement:a,rects:s,platform:c,elements:f}=o,u=function(t){let{placement:o,rects:i,value:l,rtl:a=!1}=t;const s=e(o),c=n(o),f="x"===r(o),u=["left","top"].includes(s)?-1:1;let m=1;"end"===c&&(m=-1),a&&f&&(m*=-1);const d="function"==typeof l?l({...i,placement:o}):l,{mainAxis:p,crossAxis:g}="number"==typeof d?{mainAxis:d,crossAxis:0}:{mainAxis:0,crossAxis:0,...d};return f?{x:g*m,y:p*u}:{x:p*u,y:g*m}}({placement:a,rects:s,value:t,rtl:await(null==c.isRTL?void 0:c.isRTL(f.reference))});return{x:i+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:i,placement:l}=n,{mainAxis:a=!0,crossAxis:c=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=t,d={x:o,y:i},p=await s(n,m),g=r(e(l)),h=b(g);let y=d[g],x=d[h];if(a){const t="y"===g?"bottom":"right";y=u(y+p["y"===g?"top":"left"],y,y-p[t])}if(c){const t="y"===h?"bottom":"right";x=u(x+p["y"===h?"top":"left"],x,x-p[t])}const w=f.fn({...n,[g]:y,[h]:x});return{...w,data:{x:w.x-o,y:w.y-i}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(r){const{placement:o,rects:i,platform:l,elements:a}=r,{apply:c,...u}=t,m=await s(r,u),d=e(o),p=n(o);let g,h;"top"===d||"bottom"===d?(g=d,h=p===(await(null==l.isRTL?void 0:l.isRTL(a.reference))?"start":"end")?"left":"right"):(h=d,g="end"===p?"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:i.floating.height-(["left","right"].includes(o)?2*(0!==w||0!==v?w+v:f(m.top,m.bottom)):m[g]),width:i.floating.width-(["top","bottom"].includes(o)?2*(0!==y||0!==x?y+x:f(m.left,m.right)):m[h])};return null==c||c({...b,...i}),{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 o(t){return["top","bottom"].includes(e(t))?"x":"y"}function i(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=o(r),m=i(u),d=a[m]/2-s[m]/2,p="x"===u;let g;switch(e(r)){case"top":g={x:f,y:a.y-s.height};break;case"bottom":g={x:f,y:a.y+a.height};break;case"right":g={x:a.x+a.width,y:c};break;case"left":g={x:a.x-s.width,y:c};break;default:g={x:a.x,y:a.y}}switch(n(r)){case"start":g[u]-=d*(l&&p?-1:1);break;case"end":g[u]+=d*(l&&p?-1:1)}return 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:o,y:i,platform:r,rects:s,elements:f,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:p=!1,padding:g=0}=e,h=l(g),y=f[p?"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:o,y:i}: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 p(t,e,r){void 0===r&&(r=!1);const l=n(t),a=o(t),s=i(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 g={start:"end",end:"start"};function h(t){return t.replace(/start|end/g,(t=>g[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),p={x:a,y:s},g=o(f),h=i(g),y=await m.getDimensions(n),x="y"===g?"top":"left",w="y"===g?"bottom":"right",v=c.reference[h]+c.reference[g]-p[g]-c.floating[h],b=p[g]-c.reference[g],R=await(null==m.getOffsetParent?void 0:m.getOffsetParent(n)),A=R?"y"===g?R.clientHeight||0:R.clientWidth||0:0,P=v/2-b/2,T=d[x],O=A-y[h]-d[w],k=A/2-y[h]/2+P,L=u(T,k,O);return{data:{[g]:L,centerOffset:k-L}}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(o){var i,r,l,a,f;const{x:c,y:u,rects:m,middlewareData:d,placement:g,platform:y,elements:w}=o,{alignment:v=null,allowedPlacements:b=x,autoAlignment:R=!0,...A}=t,P=function(t,o,i){return(t?[...i.filter((e=>n(e)===t)),...i.filter((e=>n(e)!==t))]:i.filter((t=>e(t)===t))).filter((e=>!t||n(e)===t||!!o&&h(e)!==e))}(v,R,b),T=await s(o,A),O=null!=(i=null==(r=d.autoPlacement)?void 0:r.index)?i:0,k=P[O],{main:L,cross:C}=p(k,m,await(null==y.isRTL?void 0:y.isRTL(w.floating)));if(g!==k)return{x:c,y:u,reset:{skip:!1,placement:P[0]}};const D=[T[e(k)],T[L],T[C]],E=[...null!=(l=null==(a=d.autoPlacement)?void 0:a.overflows)?l:[],{placement:k,overflows:D}],B=P[O+1];if(B)return{data:{index:O+1,overflows:E},reset:{skip:!1,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;return{reset:{placement:null!=V?V:H[0].placement}}}}},t.computePosition=async(t,e,n)=>{const{placement:o="bottom",strategy:i="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:i}),{x:c,y:u}=r(f,o,s),m=o,d={};const p=new Set;for(let n=0;n<l.length;n++){const{name:g,fn:h}=l[n];if(p.has(g))continue;const{x:y,y:x,data:w,reset:v}=await h({x:c,y:u,initialPlacement:o,placement:m,strategy:i,middlewareData:d,rects:f,platform:a,elements:{reference:t,floating:e}});c=null!=y?y:c,u=null!=x?x:u,d={...d,[g]:{...d[g],...w}},v&&("object"==typeof v&&(v.placement&&(m=v.placement),v.rects&&(f=!0===v.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):v.rects),({x:c,y:u}=r(f,m,s)),!1!==v.skip&&p.add(g)),n=-1)}return{x:c,y:u,placement:m,strategy:i,middlewareData:d}},t.detectOverflow=s,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(n){var o;const{placement:i,middlewareData:r,rects:l,initialPlacement:a,platform:f,elements:c}=n,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",flipAlignment:x=!0,...w}=t,v=e(i),b=g||(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==(o=r.flip)?void 0:o.overflows)||[];if(u&&P.push(A[v]),m){const{main:t,cross:e}=p(i,l,await(null==f.isRTL?void 0:f.isRTL(c.floating)));P.push(A[t],A[e])}if(T=[...T,{placement:i,overflows:P}],!P.every((t=>t<=0))){var O,k;const t=(null!=(O=null==(k=r.flip)?void 0:k.index)?O:0)+1,e=R[t];if(e)return{data:{index:t,overflows:T},reset:{skip:!1,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}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:o}=t;switch(e){case"referenceHidden":{const e=w(await s(t,{...n,elementContext:"reference"}),o.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:v(e)}}}case"escaped":{const e=w(await s(t,{...n,altBoundary:!0}),o.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 i;const{placement:r,elements:s,rects:u,platform:m,strategy:d}=n,{padding:p=2,x:g,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!=(i=await(null==m.getClientRects?void 0:m.getClientRects(s.reference)))?i:[],w=l(p);return{reset:{rects:await m.getElementRects({reference:{getBoundingClientRect:function(){var t;if(2===x.length&&x[0].left>x[1].right&&null!=g&&null!=h)return null!=(t=x.find((t=>g>t.left-w.left&&g<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)))?t:y;if(x.length>=2){if("x"===o(r)){const t=x[0],n=x[x.length-1],o="top"===e(r),i=t.top,l=n.bottom,a=o?t.left:n.left,s=o?t.right:n.right;return{top:i,bottom:l,left:a,right:s,width:s-a,height:l-i,x:a,y:i}}const t="left"===e(r),n=c(...x.map((t=>t.right))),i=f(...x.map((t=>t.left))),l=x.filter((e=>t?e.left===i:e.right===n)),a=l[0].top,s=l[l.length-1].bottom;return{top:a,bottom:s,left:i,right:n,width:n-i,height:s-a,x:i,y:a}}return y}},floating:s.floating,strategy:d})}}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(n){const{x:i,y:r,placement:l,rects:a,middlewareData:s}=n,{offset:f=0,mainAxis:c=!0,crossAxis:u=!0}=t,m={x:i,y:r},d=o(l),p=b(d);let g=m[d],h=m[p];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;g<e?g=e:g>n&&(g=n)}if(u){var w,v,R,A;const t="y"===d?"width":"height",n=["top","left"].includes(e(l)),o=a.reference[p]-a.floating[t]+(n&&null!=(w=null==(v=s.offset)?void 0:v[p])?w:0)+(n?0:x.crossAxis),i=a.reference[p]+a.reference[t]+(n?0:null!=(R=null==(A=s.offset)?void 0:A[p])?R:0)-(n?x.crossAxis:0);h<o?h=o:h>i&&(h=i)}return{[d]:g,[p]:h}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(i){const{x:r,y:l,placement:a,rects:s,platform:f,elements:c}=i,u=function(t,i,r,l){void 0===l&&(l=!1);const a=e(t),s=n(t),f="x"===o(t),c=["left","top"].includes(a)?-1:1;let u=1;"end"===s&&(u=-1),l&&f&&(u*=-1);const m="function"==typeof r?r({...i,placement:t}):r,{mainAxis:d,crossAxis:p}="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};return f?{x:p*u,y:d*c}:{x:d*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:i,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:i,y:r},p=await s(n,m),g=o(e(l)),h=b(g);let y=d[g],x=d[h];if(a){const t="y"===g?"bottom":"right";y=u(y+p["y"===g?"top":"left"],y,y-p[t])}if(f){const t="y"===h?"bottom":"right";x=u(x+p["y"===h?"top":"left"],x,x-p[t])}const w=c.fn({...n,[g]:y,[h]:x});return{...w,data:{x:w.x-i,y:w.y-r}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(o){const{placement:i,rects:r,platform:l,elements:a}=o,{apply:f,...u}=t,m=await s(o,u),d=e(i),p=n(i);let g,h;"top"===d||"bottom"===d?(g=d,h=p===(await(null==l.isRTL?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(h=d,g="end"===p?"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(i)?2*(0!==w||0!==v?w+v:c(m.top,m.bottom)):m[g]),width:r.floating.width-(["top","bottom"].includes(i)?2*(0!==y||0!==x?y+x:c(m.left,m.right)):m[h])};return null==f||f({...b,...r}),{reset:{rects:!0}}}}},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@floating-ui/core",
"version": "0.5.0",
"version": "0.5.1",
"@rollingversions": {

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

import type { Placement, ElementRects, Coords } from './types';
export declare function computeCoordsFromPlacement({ reference, floating, placement, rtl, }: ElementRects & {
placement: Placement;
rtl?: boolean;
}): Coords;
export declare function computeCoordsFromPlacement({ reference, floating }: ElementRects, placement: Placement, rtl?: boolean): Coords;

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

import type { Placement, Rect, Coords, Middleware } from '../types';
import type { Placement, Rect, Coords, Middleware, ElementRects } from '../types';
declare type OffsetValue = number | {

@@ -18,11 +18,3 @@ /**

export declare type Options = OffsetValue | OffsetFunction;
export declare function convertValueToCoords({ placement, rects, value, rtl, }: {
placement: Placement;
rects: {
floating: Rect;
reference: Rect;
};
value: Options;
rtl?: boolean;
}): Coords;
export declare function convertValueToCoords(placement: Placement, rects: ElementRects, value: Options, rtl?: boolean): Coords;
/**

@@ -29,0 +21,0 @@ * Displaces the floating element from its reference element.

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