Socket
Socket
Sign inDemoInstall

@floating-ui/core

Package Overview
Dependencies
Maintainers
1
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.2.1 to 0.2.2

src/utils/math.d.ts

34

dist/floating-ui.core.esm.js

@@ -89,3 +89,3 @@ function getBasePlacement(placement) {

if (platform == null) {
throw new Error(['Floating UI Core: `platform` property was not passed.'].join(' '));
console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
}

@@ -284,4 +284,7 @@

function within(min, value, max) {
return Math.max(min, Math.min(value, max));
const min = Math.min;
const max = Math.max;
function within(min$1, value, max$1) {
return max(min$1, min(value, max$1));
}

@@ -387,6 +390,7 @@

const basePlacements = ['top', 'right', 'bottom', 'left'];
const allPlacements = basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);
const allPlacements = /*#__PURE__*/basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
return allowedPlacements.filter(placement => {
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getBasePlacement(placement) === placement);
return allowedPlacementsSortedByAlignment.filter(placement => {
if (alignment) {

@@ -396,3 +400,3 @@ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);

return getBasePlacement(placement) === placement;
return true;
});

@@ -420,3 +424,2 @@ }

alignment = null,
crossAxis = false,
allowedPlacements = allPlacements,

@@ -469,3 +472,3 @@ autoAlignment = true,

const placementsSortedByLeastOverflow = allOverflows.slice().sort(crossAxis || autoAlignment && getAlignment(placement) ? (a, b) => a.overflows.reduce((acc, overflow) => acc + overflow, 0) - b.overflows.reduce((acc, overflow) => acc + overflow, 0) : (a, b) => a.overflows[0] - b.overflows[0]);
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {

@@ -794,3 +797,3 @@ let {

};
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const mainAxis = getMainAxisFromPlacement(placement);
const crossAxis = getCrossAxis(mainAxis);

@@ -827,4 +830,5 @@ let mainAxisCoord = coords[mainAxis];

const len = mainAxis === 'y' ? 'width' : 'height';
const limitMin = rects.reference[crossAxis] - rects.floating[len] - ((_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[mainAxis]) != null ? _middlewareData$offse : 0) + computedOffset.crossAxis;
const limitMax = rects.reference[crossAxis] + rects.reference[len] + ((_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[mainAxis]) != null ? _middlewareData$offse3 : 0) + computedOffset.crossAxis;
const isOriginSide = ['top', 'left'].includes(getBasePlacement(placement));
const limitMin = rects.reference[crossAxis] - rects.floating[len] - ((_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[mainAxis]) != null ? _middlewareData$offse : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
const limitMax = rects.reference[crossAxis] + rects.reference[len] + ((_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[mainAxis]) != null ? _middlewareData$offse3 : 0) + (isOriginSide ? computedOffset.crossAxis : 0);

@@ -879,5 +883,9 @@ if (crossAxisCoord < limitMin) {

const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
const dimensions = {
height: rects.floating.height - overflow[heightSide],
width: rects.floating.width - overflow[widthSide]
height: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
width: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
};

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

@@ -95,3 +95,3 @@ (function (global, factory) {

if (platform == null) {
throw new Error(['Floating UI Core: `platform` property was not passed.'].join(' '));
console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
}

@@ -290,4 +290,7 @@

function within(min, value, max) {
return Math.max(min, Math.min(value, max));
const min = Math.min;
const max = Math.max;
function within(min$1, value, max$1) {
return max(min$1, min(value, max$1));
}

@@ -393,6 +396,7 @@

const basePlacements = ['top', 'right', 'bottom', 'left'];
const allPlacements = basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);
const allPlacements = /*#__PURE__*/basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
return allowedPlacements.filter(placement => {
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getBasePlacement(placement) === placement);
return allowedPlacementsSortedByAlignment.filter(placement => {
if (alignment) {

@@ -402,3 +406,3 @@ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);

return getBasePlacement(placement) === placement;
return true;
});

@@ -426,3 +430,2 @@ }

alignment = null,
crossAxis = false,
allowedPlacements = allPlacements,

@@ -475,3 +478,3 @@ autoAlignment = true,

const placementsSortedByLeastOverflow = allOverflows.slice().sort(crossAxis || autoAlignment && getAlignment(placement) ? (a, b) => a.overflows.reduce((acc, overflow) => acc + overflow, 0) - b.overflows.reduce((acc, overflow) => acc + overflow, 0) : (a, b) => a.overflows[0] - b.overflows[0]);
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {

@@ -800,3 +803,3 @@ let {

};
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const mainAxis = getMainAxisFromPlacement(placement);
const crossAxis = getCrossAxis(mainAxis);

@@ -833,4 +836,5 @@ let mainAxisCoord = coords[mainAxis];

const len = mainAxis === 'y' ? 'width' : 'height';
const limitMin = rects.reference[crossAxis] - rects.floating[len] - ((_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[mainAxis]) != null ? _middlewareData$offse : 0) + computedOffset.crossAxis;
const limitMax = rects.reference[crossAxis] + rects.reference[len] + ((_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[mainAxis]) != null ? _middlewareData$offse3 : 0) + computedOffset.crossAxis;
const isOriginSide = ['top', 'left'].includes(getBasePlacement(placement));
const limitMin = rects.reference[crossAxis] - rects.floating[len] - ((_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[mainAxis]) != null ? _middlewareData$offse : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
const limitMax = rects.reference[crossAxis] + rects.reference[len] + ((_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[mainAxis]) != null ? _middlewareData$offse3 : 0) + (isOriginSide ? computedOffset.crossAxis : 0);

@@ -885,5 +889,9 @@ if (crossAxisCoord < limitMin) {

const xMin = max(overflow.left, 0);
const xMax = max(overflow.right, 0);
const yMin = max(overflow.top, 0);
const yMax = max(overflow.bottom, 0);
const dimensions = {
height: rects.floating.height - overflow[heightSide],
width: rects.floating.width - overflow[widthSide]
height: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
width: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
};

@@ -890,0 +898,0 @@

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

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

@@ -22,4 +22,4 @@ "main": "dist/floating-ui.core.cjs",

"test": "jest test",
"build": "NODE_ENV=build rollup -c",
"dev": "rollup -c -w"
"dev": "rollup -c -w",
"build": "NODE_ENV=build rollup -c"
},

@@ -51,2 +51,3 @@ "author": "atomiks",

"@types/jest": "^27.0.3",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"jest": "^27.3.1",

@@ -53,0 +54,0 @@ "rollup": "^2.60.1",

@@ -6,3 +6,2 @@ import type { Middleware, Placement, Alignment } from '../types';

alignment: Alignment | null;
crossAxis: boolean;
allowedPlacements: Array<Placement>;

@@ -9,0 +8,0 @@ autoAlignment: boolean;

@@ -11,3 +11,3 @@ import type { Placement, Rect, Coords, Middleware } from '../types';

}) => OffsetValue;
export declare type Offset = OffsetValue | OffsetFunction;
export declare type Options = OffsetValue | OffsetFunction;
export declare function convertValueToCoords({ placement, rects, value, }: {

@@ -19,5 +19,5 @@ placement: Placement;

};
value: Offset;
value: Options;
}): Coords;
export declare const offset: (value?: Offset) => Middleware;
export declare const offset: (value?: Options) => Middleware;
export {};

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