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.2.2 to 0.3.0

src/middleware/inline.d.ts

345

dist/floating-ui.core.esm.js

@@ -156,17 +156,23 @@ function getBasePlacement(placement) {

if (reset) {
if (typeof reset === 'object' && reset.placement) {
statefulPlacement = reset.placement;
if (typeof reset === 'object') {
if (reset.placement) {
statefulPlacement = reset.placement;
}
if (reset.rects) {
rects = reset.rects === true ? await platform.getElementRects({
reference,
floating,
strategy
}) : reset.rects;
}
({
x,
y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
}));
}
rects = await platform.getElementRects({
reference,
floating,
strategy
});
({
x,
y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
}));
i = -1;

@@ -253,6 +259,3 @@ continue;

strategy
})); // Debug the client rects:
// draw(clippingClientRect, 'cyan', 1);
// draw(elementClientRect, 'yellow', 2);
// positive = overflowing the clipping rect
})); // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect

@@ -266,20 +269,3 @@

};
} // function draw(rect, color, id) {
// const lastDraw = document.querySelector(`#draw-${id}`);
// if (document.body.contains(lastDraw)) {
// document.body.removeChild(lastDraw);
// }
// const div = document.createElement('div');
// div.id = `draw-${id}`;
// Object.assign(div.style, {
// position: 'absolute',
// left: `${rect.x}px`,
// top: `${rect.y}px`,
// width: `${rect.width}px`,
// height: `${rect.height}px`,
// backgroundColor: color,
// opacity: '0.5',
// });
// document.body.append(div);
// }
}

@@ -295,2 +281,3 @@ const min = Math.min;

name: 'arrow',
options,

@@ -337,5 +324,3 @@ async fn(middlewareArguments) {

});
const clientSize = arrowOffsetParent ? axis === 'y' ? // @ts-ignore - fallback to 0
arrowOffsetParent.clientHeight || 0 : // @ts-ignore - fallback to 0
arrowOffsetParent.clientWidth || 0 : 0;
const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center

@@ -412,2 +397,3 @@ // point is outside of the floating element's bounds

name: 'autoPlacement',
options,

@@ -505,2 +491,3 @@ async fn(middlewareArguments) {

name: 'flip',
options,

@@ -686,2 +673,3 @@ async fn(middlewareArguments) {

name: 'offset',
options: value,

@@ -721,2 +709,3 @@ fn(middlewareArguments) {

name: 'shift',
options,

@@ -732,11 +721,13 @@ async fn(middlewareArguments) {

crossAxis: checkCrossAxis = false,
limiter = _ref => {
let {
x,
y
} = _ref;
return {
x,
y
};
limiter = {
fn: _ref => {
let {
x,
y
} = _ref;
return {
x,
y
};
}
},

@@ -771,6 +762,12 @@ ...detectOverflowOptions

return limiter({ ...middlewareArguments,
const limitedCoords = limiter.fn({ ...middlewareArguments,
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
});
return { ...limitedCoords,
data: {
x: limitedCoords.x - x,
y: limitedCoords.y - y
}
};
}

@@ -785,66 +782,71 @@

return middlewareArguments => {
const {
x,
y,
placement,
rects,
middlewareData
} = middlewareArguments;
const {
offset = 0,
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true
} = options;
const coords = {
x,
y
};
const mainAxis = getMainAxisFromPlacement(placement);
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const rawOffset = typeof offset === 'function' ? offset({ ...rects,
placement
}) : offset;
const computedOffset = typeof rawOffset === 'number' ? {
mainAxis: rawOffset,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
};
return {
options,
if (checkMainAxis) {
const len = mainAxis === 'y' ? 'height' : 'width';
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
fn(middlewareArguments) {
const {
x,
y,
placement,
rects,
middlewareData
} = middlewareArguments;
const {
offset = 0,
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true
} = options;
const coords = {
x,
y
};
const mainAxis = getMainAxisFromPlacement(placement);
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const rawOffset = typeof offset === 'function' ? offset({ ...rects,
placement
}) : offset;
const computedOffset = typeof rawOffset === 'number' ? {
mainAxis: rawOffset,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
};
if (mainAxisCoord < limitMin) {
mainAxisCoord = limitMin;
} else if (mainAxisCoord > limitMax) {
mainAxisCoord = limitMax;
if (checkMainAxis) {
const len = mainAxis === 'y' ? 'height' : 'width';
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
if (mainAxisCoord < limitMin) {
mainAxisCoord = limitMin;
} else if (mainAxisCoord > limitMax) {
mainAxisCoord = limitMax;
}
}
}
if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
const len = mainAxis === 'y' ? 'width' : 'height';
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);
const len = mainAxis === 'y' ? 'width' : 'height';
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);
if (crossAxisCoord < limitMin) {
crossAxisCoord = limitMin;
} else if (crossAxisCoord > limitMax) {
crossAxisCoord = limitMax;
if (crossAxisCoord < limitMin) {
crossAxisCoord = limitMin;
} else if (crossAxisCoord > limitMax) {
crossAxisCoord = limitMax;
}
}
return {
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
};
}
return {
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
};
};

@@ -860,2 +862,3 @@ };

name: 'size',
options,

@@ -874,2 +877,7 @@ async fn(middlewareArguments) {

} = options;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);

@@ -897,10 +905,121 @@ const basePlacement = getBasePlacement(placement);

};
apply == null ? void 0 : apply({ ...dimensions,
...rects
});
return {
data: {
skip: true
},
reset: {
rects: true
}
};
}
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
};
};
const inline = function (options) {
if (options === void 0) {
options = {};
}
return {
name: 'inline',
options,
async fn(middlewareArguments) {
var _middlewareData$inlin, _await$platform$getCl;
const {
placement,
elements,
rects,
platform,
strategy,
middlewareData
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
// ClientRect's bounds, despite the event listener being triggered. A
// padding of 2 seems to handle this issue.
const {
padding = 2,
x,
y
} = options;
if ((_middlewareData$inlin = middlewareData.inline) != null && _middlewareData$inlin.skip) {
return {};
}
apply == null ? void 0 : apply({ ...dimensions,
...rects
});
const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
strategy
}));
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects({
element: elements.reference
}))) != null ? _await$platform$getCl : []);
const paddingObject = getSideObjectFromPadding(padding);
function getBoundingClientRect() {
// There are two rects and they are disjoined
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
var _clientRects$find;
// Find the first rect in which the point is fully inside
return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
} // There are 2 or more connected rects
if (clientRects.length >= 2) {
if (getMainAxisFromPlacement(placement) === 'x') {
const firstRect = clientRects[0];
const lastRect = clientRects[clientRects.length - 1];
const isTop = getBasePlacement(placement) === 'top';
const top = firstRect.top;
const bottom = lastRect.bottom;
const left = isTop ? firstRect.left : lastRect.left;
const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
}
const isLeftPlacement = getBasePlacement(placement) === 'left';
const maxRight = max(...clientRects.map(rect => rect.right));
const minLeft = min(...clientRects.map(rect => rect.left));
const measureRects = clientRects.filter(rect => isLeftPlacement ? rect.left === minLeft : rect.right === maxRight);
const top = measureRects[0].top;
const bottom = measureRects[measureRects.length - 1].bottom;
const left = minLeft;
const right = maxRight;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
}
return fallback;
}
return {

@@ -910,3 +1029,11 @@ data: {

},
reset: true
reset: {
rects: await platform.getElementRects({
reference: {
getBoundingClientRect
},
floating: elements.floating,
strategy
})
}
};

@@ -918,2 +1045,2 @@ }

export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, limitShift, offset, rectToClientRect, shift, size };
export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, rectToClientRect, shift, size };

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

@@ -162,17 +162,23 @@ (function (global, factory) {

if (reset) {
if (typeof reset === 'object' && reset.placement) {
statefulPlacement = reset.placement;
if (typeof reset === 'object') {
if (reset.placement) {
statefulPlacement = reset.placement;
}
if (reset.rects) {
rects = reset.rects === true ? await platform.getElementRects({
reference,
floating,
strategy
}) : reset.rects;
}
({
x,
y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
}));
}
rects = await platform.getElementRects({
reference,
floating,
strategy
});
({
x,
y
} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
}));
i = -1;

@@ -259,6 +265,3 @@ continue;

strategy
})); // Debug the client rects:
// draw(clippingClientRect, 'cyan', 1);
// draw(elementClientRect, 'yellow', 2);
// positive = overflowing the clipping rect
})); // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect

@@ -272,20 +275,3 @@

};
} // function draw(rect, color, id) {
// const lastDraw = document.querySelector(`#draw-${id}`);
// if (document.body.contains(lastDraw)) {
// document.body.removeChild(lastDraw);
// }
// const div = document.createElement('div');
// div.id = `draw-${id}`;
// Object.assign(div.style, {
// position: 'absolute',
// left: `${rect.x}px`,
// top: `${rect.y}px`,
// width: `${rect.width}px`,
// height: `${rect.height}px`,
// backgroundColor: color,
// opacity: '0.5',
// });
// document.body.append(div);
// }
}

@@ -301,2 +287,3 @@ const min = Math.min;

name: 'arrow',
options,

@@ -343,5 +330,3 @@ async fn(middlewareArguments) {

});
const clientSize = arrowOffsetParent ? axis === 'y' ? // @ts-ignore - fallback to 0
arrowOffsetParent.clientHeight || 0 : // @ts-ignore - fallback to 0
arrowOffsetParent.clientWidth || 0 : 0;
const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center

@@ -418,2 +403,3 @@ // point is outside of the floating element's bounds

name: 'autoPlacement',
options,

@@ -511,2 +497,3 @@ async fn(middlewareArguments) {

name: 'flip',
options,

@@ -692,2 +679,3 @@ async fn(middlewareArguments) {

name: 'offset',
options: value,

@@ -727,2 +715,3 @@ fn(middlewareArguments) {

name: 'shift',
options,

@@ -738,11 +727,13 @@ async fn(middlewareArguments) {

crossAxis: checkCrossAxis = false,
limiter = _ref => {
let {
x,
y
} = _ref;
return {
x,
y
};
limiter = {
fn: _ref => {
let {
x,
y
} = _ref;
return {
x,
y
};
}
},

@@ -777,6 +768,12 @@ ...detectOverflowOptions

return limiter({ ...middlewareArguments,
const limitedCoords = limiter.fn({ ...middlewareArguments,
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
});
return { ...limitedCoords,
data: {
x: limitedCoords.x - x,
y: limitedCoords.y - y
}
};
}

@@ -791,66 +788,71 @@

return middlewareArguments => {
const {
x,
y,
placement,
rects,
middlewareData
} = middlewareArguments;
const {
offset = 0,
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true
} = options;
const coords = {
x,
y
};
const mainAxis = getMainAxisFromPlacement(placement);
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const rawOffset = typeof offset === 'function' ? offset({ ...rects,
placement
}) : offset;
const computedOffset = typeof rawOffset === 'number' ? {
mainAxis: rawOffset,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
};
return {
options,
if (checkMainAxis) {
const len = mainAxis === 'y' ? 'height' : 'width';
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
fn(middlewareArguments) {
const {
x,
y,
placement,
rects,
middlewareData
} = middlewareArguments;
const {
offset = 0,
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true
} = options;
const coords = {
x,
y
};
const mainAxis = getMainAxisFromPlacement(placement);
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const rawOffset = typeof offset === 'function' ? offset({ ...rects,
placement
}) : offset;
const computedOffset = typeof rawOffset === 'number' ? {
mainAxis: rawOffset,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...rawOffset
};
if (mainAxisCoord < limitMin) {
mainAxisCoord = limitMin;
} else if (mainAxisCoord > limitMax) {
mainAxisCoord = limitMax;
if (checkMainAxis) {
const len = mainAxis === 'y' ? 'height' : 'width';
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
if (mainAxisCoord < limitMin) {
mainAxisCoord = limitMin;
} else if (mainAxisCoord > limitMax) {
mainAxisCoord = limitMax;
}
}
}
if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
const len = mainAxis === 'y' ? 'width' : 'height';
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);
const len = mainAxis === 'y' ? 'width' : 'height';
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);
if (crossAxisCoord < limitMin) {
crossAxisCoord = limitMin;
} else if (crossAxisCoord > limitMax) {
crossAxisCoord = limitMax;
if (crossAxisCoord < limitMin) {
crossAxisCoord = limitMin;
} else if (crossAxisCoord > limitMax) {
crossAxisCoord = limitMax;
}
}
return {
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
};
}
return {
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
};
};

@@ -866,2 +868,3 @@ };

name: 'size',
options,

@@ -880,2 +883,7 @@ async fn(middlewareArguments) {

} = options;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);

@@ -903,10 +911,121 @@ const basePlacement = getBasePlacement(placement);

};
apply == null ? void 0 : apply({ ...dimensions,
...rects
});
return {
data: {
skip: true
},
reset: {
rects: true
}
};
}
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
};
};
const inline = function (options) {
if (options === void 0) {
options = {};
}
return {
name: 'inline',
options,
async fn(middlewareArguments) {
var _middlewareData$inlin, _await$platform$getCl;
const {
placement,
elements,
rects,
platform,
strategy,
middlewareData
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
// ClientRect's bounds, despite the event listener being triggered. A
// padding of 2 seems to handle this issue.
const {
padding = 2,
x,
y
} = options;
if ((_middlewareData$inlin = middlewareData.inline) != null && _middlewareData$inlin.skip) {
return {};
}
apply == null ? void 0 : apply({ ...dimensions,
...rects
});
const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
strategy
}));
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects({
element: elements.reference
}))) != null ? _await$platform$getCl : []);
const paddingObject = getSideObjectFromPadding(padding);
function getBoundingClientRect() {
// There are two rects and they are disjoined
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
var _clientRects$find;
// Find the first rect in which the point is fully inside
return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
} // There are 2 or more connected rects
if (clientRects.length >= 2) {
if (getMainAxisFromPlacement(placement) === 'x') {
const firstRect = clientRects[0];
const lastRect = clientRects[clientRects.length - 1];
const isTop = getBasePlacement(placement) === 'top';
const top = firstRect.top;
const bottom = lastRect.bottom;
const left = isTop ? firstRect.left : lastRect.left;
const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
}
const isLeftPlacement = getBasePlacement(placement) === 'left';
const maxRight = max(...clientRects.map(rect => rect.right));
const minLeft = min(...clientRects.map(rect => rect.left));
const measureRects = clientRects.filter(rect => isLeftPlacement ? rect.left === minLeft : rect.right === maxRight);
const top = measureRects[0].top;
const bottom = measureRects[measureRects.length - 1].bottom;
const left = minLeft;
const right = maxRight;
const width = right - left;
const height = bottom - top;
return {
top,
bottom,
left,
right,
width,
height,
x: left,
y: top
};
}
return fallback;
}
return {

@@ -916,3 +1035,11 @@ data: {

},
reset: true
reset: {
rects: await platform.getElementRects({
reference: {
getBoundingClientRect
},
floating: elements.floating,
strategy
})
}
};

@@ -930,2 +1057,3 @@ }

exports.hide = hide;
exports.inline = inline;
exports.limitShift = limitShift;

@@ -932,0 +1060,0 @@ exports.offset = offset;

@@ -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 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})}));
!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:l,placement:a}=t;const s=i.x+i.width/2-l.width/2,c=i.y+i.height/2-l.height/2;let f;switch(e(a)){case"top":f={x:s,y:i.y-l.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-l.width,y:c};break;default:f={x:i.x,y:i.y}}const u=o(a),m=r(u);switch(n(a)){case"start":f[u]=f[u]-(i[m]/2-l[m]/2);break;case"end":f[u]=f[u]+(i[m]/2-l[m]/2)}return f}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){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=l(d),h=s[p?"floating"===m?"reference":"floating":m],y=await r.getClippingClientRect({element:await r.isElement(h)?h:h.contextElement||await r.getDocumentElement({element:s.floating}),boundary:f,rootBoundary:u}),x=a(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:y.top-x.top+g.top,bottom:x.bottom-y.bottom+g.bottom,left:y.left-x.left+g.left,right:x.right-y.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),l=o(t),a=r(l);let s="x"===l?i?"right":"left":i?"bottom":"top";return e.reference[a]>e.floating[a]&&(s=p(s)),{main:s,cross:p(s)}}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 b(t){return y.some((e=>t[e]>=0))}function v(t){return"x"===t?"y":"x"}t.arrow=t=>({name:"arrow",options:t,async fn(n){const{element:i,padding:a=0}=null!=t?t:{},{x:s,y:c,placement:f,rects:m,platform:p}=n;if(null==i)return{};const d=l(a),g={x:s,y:c},h=o(e(f)),y=r(h),x=await p.getDimensions({element:i}),w="y"===h?"top":"left",b="y"===h?"bottom":"right",v=m.reference[y]+m.reference[h]-g[h]-m.floating[y],A=g[h]-m.reference[h],P=await p.getOffsetParent({element:i}),k=P?"y"===h?P.clientHeight||0:P.clientWidth||0:0,R=v/2-A/2,O=d[w],C=k-x[y]-d[b],D=k/2-x[y]/2+R,E=u(O,D,C);return{data:{[h]:E,centerOffset:D-E}}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(o){var r,i,l,a,c,f;const{x:u,y:m,rects:p,middlewareData:g,placement:y}=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&&h(e)!==e))}(w,v,b),k=await s(o,A),R=null!=(i=null==(l=g.autoPlacement)?void 0:l.index)?i:0,O=P[R],{main:C,cross:D}=d(O,p);if(y!==O)return{x:u,y:m,reset:{placement:P[0]}};const E=[k[e(O)],k[C],k[D]],B=[...null!=(a=null==(c=g.autoPlacement)?void 0:c.overflows)?a:[],{placement:O,overflows:E}],T=P[R+1];if(T)return{data:{index:R+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:l=[],platform:a}=n;let s=await a.getElementRects({reference:t,floating:e,strategy:r}),{x:c,y:f}=i({...s,placement:o}),u=o,m={};for(let n=0;n<l.length;n++){const{name:p,fn:d}=l[n],{x:g,y:h,data:y,reset:x}=await d({x:c,y:f,initialPlacement:o,placement:u,strategy:r,middlewareData:m,rects:s,platform:a,elements:{reference:t,floating:e}});c=null!=g?g:c,f=null!=h?h:f,m={...m,[p]:null!=y?y:{}},x&&("object"==typeof x&&(x.placement&&(u=x.placement),x.rects&&(s=!0===x.rects?await a.getElementRects({reference:t,floating:e,strategy:r}):x.rects),({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",options:t,async fn(n){var o,r;const{placement:i,middlewareData:l,rects:a,initialPlacement:c}=n;if(null!=(o=l.flip)&&o.skip)return{};const{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",flipAlignment:y=!0,...x}=t,w=e(i),b=m||(w===c||!y?[p(c)]:function(t){const e=p(t);return[h(t),e,h(e)]}(c)),v=[c,...b],A=await s(n,x),P=[];let k=(null==(r=l.flip)?void 0:r.overflows)||[];if(f&&P.push(A[w]),u){const{main:t,cross:e}=d(i,a);P.push(A[t],A[e])}if(k=[...k,{placement:i,overflows:P}],!P.every((t=>t<=0))){var R,O;const t=(null!=(R=null==(O=l.flip)?void 0:O.index)?R:0)+1,e=v[t];if(e)return{data:{index:t,overflows:k},reset:{placement:e}};let n="bottom";switch(g){case"bestFit":{var C;const t=null==(C=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:C.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.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(n){var r,i;const{placement:s,elements:u,rects:m,platform:p,strategy:d,middlewareData:g}=n,{padding:h=2,x:y,y:x}=t;if(null!=(r=g.inline)&&r.skip)return{};const w=a(await p.convertOffsetParentRelativeRectToViewportRelativeRect({rect:m.reference,offsetParent:await p.getOffsetParent({element:u.floating}),strategy:d})),b=Array.from(null!=(i=await(null==p.getClientRects?void 0:p.getClientRects({element:u.reference})))?i:[]),v=l(h);return{data:{skip:!0},reset:{rects:await p.getElementRects({reference:{getBoundingClientRect:function(){var t;if(2===b.length&&b[0].left>b[1].right&&null!=y&&null!=x)return null!=(t=b.find((t=>y>t.left-v.left&&y<t.right+v.right&&x>t.top-v.top&&x<t.bottom+v.bottom)))?t:w;if(b.length>=2){if("x"===o(s)){const t=b[0],n=b[b.length-1],o="top"===e(s),r=t.top,i=n.bottom,l=o?t.left:n.left,a=o?t.right:n.right;return{top:r,bottom:i,left:l,right:a,width:a-l,height:i-r,x:l,y:r}}const t="left"===e(s),n=f(...b.map((t=>t.right))),r=c(...b.map((t=>t.left))),i=b.filter((e=>t?e.left===r:e.right===n)),l=i[0].top,a=i[i.length-1].bottom;return{top:l,bottom:a,left:r,right:n,width:n-r,height:a-l,x:r,y:l}}return w}},floating:u.floating,strategy:d})}}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(n){const{x:r,y:i,placement:l,rects:a,middlewareData:s}=n,{offset:c=0,mainAxis:f=!0,crossAxis:u=!0}=t,m={x:r,y:i},p=o(l),d=v(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,b,A,P;const t="y"===p?"width":"height",n=["top","left"].includes(e(l)),o=a.reference[d]-a.floating[t]-(null!=(w=null==(b=s.offset)?void 0:b[p])?w:0)+(n?0:x.crossAxis),r=a.reference[d]+a.reference[t]+(null!=(A=null==(P=s.offset)?void 0:P[p])?A:0)-(n?x.crossAxis:0);h<o?h=o:h>r&&(h=r)}return{[p]:g,[d]:h}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,fn(n){const{x:r,y:i,placement:l,rects:a}=n,s=function(t){let{placement:n,rects:r,value:i}=t;const l=e(n),a=["left","top"].includes(l)?-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(l)?{x:f,y:c*a}:{x:c*a,y:f}}({placement:l,rects:a,value:t});return{x:r+s.x,y:i+s.y,data:s}}}},t.rectToClientRect=a,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(n){const{x:r,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,p={x:r,y:i},d=await s(n,m),g=o(e(l)),h=v(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({...n,[g]:y,[h]:x});return{...w,data:{x:w.x-r,y:w.y-i}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(o){var r;const{placement:i,rects:l,middlewareData:a}=o,{apply:c,...u}=t;if(null!=(r=a.size)&&r.skip)return{};const m=await s(o,u),p=e(i),d="end"===n(i);let g,h;"top"===p||"bottom"===p?(g=p,h=d?"left":"right"):(h=p,g=d?"top":"bottom");const y=f(m.left,0),x=f(m.right,0),w=f(m.top,0),b=f(m.bottom,0),v={height:l.floating.height-(["left","right"].includes(i)?2*(0!==w||0!==b?w+b:f(m.top,m.bottom)):m[g]),width:l.floating.width-(["top","bottom"].includes(i)?2*(0!==y||0!==x?y+x:f(m.left,m.right)):m[h])};return null==c||c({...v,...l}),{data:{skip:!0},reset:{rects:!0}}}}},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@floating-ui/core",
"version": "0.2.2",
"version": "0.3.0",
"@rollingversions": {
"baseVersion": [
0,
0,
0
]
},
"description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",
"publishConfig": {
"access": "public"
},
"main": "dist/floating-ui.core.cjs",

@@ -10,4 +20,7 @@ "module": "dist/floating-ui.core.esm.js",

"exports": {
"import": "./dist/floating-ui.core.esm.js",
"require": "./dist/floating-ui.core.cjs"
".": {
"import": "./dist/floating-ui.core.esm.js",
"require": "./dist/floating-ui.core.cjs"
},
"./package.json": "./package.json"
},

@@ -14,0 +27,0 @@ "sideEffects": false,

@@ -10,2 +10,3 @@ export { computePosition } from './computePosition';

export { size } from './middleware/size';
export { inline } from './middleware/inline';
export { rectToClientRect } from './utils/rectToClientRect';

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

crossAxis: boolean;
limiter: (middlewareArguments: MiddlewareArguments) => Coords;
limiter: {
fn: (middlewareArguments: MiddlewareArguments) => Coords;
options?: any;
};
};

@@ -26,3 +29,6 @@ export declare const shift: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;

};
export declare const limitShift: (options?: Partial<LimitShiftOptions>) => (middlewareArguments: MiddlewareArguments) => Coords;
export declare const limitShift: (options?: Partial<LimitShiftOptions>) => {
options: Partial<LimitShiftOffset>;
fn: (middlewareArguments: MiddlewareArguments) => Coords;
};
export {};

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

import { Dimensions, ElementRects, Middleware } from '../types';
import type { Dimensions, ElementRects, Middleware } from '../types';
import { Options as DetectOverflowOptions } from '../detectOverflow';

@@ -3,0 +3,0 @@ export declare type Options = {

@@ -0,8 +1,9 @@

export declare type Alignment = 'start' | 'end';
export declare type BasePlacement = 'top' | 'right' | 'bottom' | 'left';
export declare type AlignedPlacement = 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end';
export declare type AlignedPlacement = `${BasePlacement}-${Alignment}`;
export declare type Placement = BasePlacement | AlignedPlacement;
export declare type Strategy = 'absolute' | 'fixed';
export declare type Alignment = 'start' | 'end';
export declare type Axis = 'x' | 'y';
export declare type Length = 'width' | 'height';
declare type Promisable<T> = T | Promise<T>;
export declare type Platform = {

@@ -13,3 +14,3 @@ getElementRects: (args: {

strategy: Strategy;
}) => ElementRects | Promise<ElementRects>;
}) => Promisable<ElementRects>;
convertOffsetParentRelativeRectToViewportRelativeRect: (args: {

@@ -19,10 +20,10 @@ rect: Rect;

strategy: Strategy;
}) => Rect | Promise<Rect>;
}) => Promisable<Rect>;
getOffsetParent: (args: {
element: any;
}) => any | Promise<any>;
isElement: (value: unknown) => boolean | Promise<boolean>;
}) => Promisable<any>;
isElement: (value: unknown) => Promisable<boolean>;
getDocumentElement: (args: {
element: any;
}) => any | Promise<any>;
}) => Promisable<any>;
getClippingClientRect: (args: {

@@ -32,21 +33,18 @@ element: any;

rootBoundary: RootBoundary;
}) => ClientRectObject | Promise<ClientRectObject>;
}) => Promisable<ClientRectObject>;
getDimensions: (args: {
element: any;
}) => Dimensions | Promise<Dimensions>;
}) => Promisable<Dimensions>;
getClientRects?: (args: {
element: any;
}) => Promisable<Array<ClientRectObject>>;
};
export declare type Coords = {
x: number;
y: number;
[key in Axis]: number;
};
export declare type SideObject = {
top: number;
right: number;
bottom: number;
left: number;
[key in BasePlacement]: number;
};
export declare type MiddlewareData = {
arrow?: {
x?: number;
y?: number;
arrow?: Partial<Coords> & {
centerOffset: number;

@@ -76,2 +74,5 @@ };

};
inline?: {
skip?: boolean;
};
size?: {

@@ -89,5 +90,3 @@ skip?: boolean;

};
export declare type ComputePositionReturn = {
x: number;
y: number;
export declare type ComputePositionReturn = Coords & {
placement: Placement;

@@ -104,2 +103,3 @@ strategy: Strategy;

placement?: Placement;
rects?: true | ElementRects;
};

@@ -109,7 +109,7 @@ }>;

name: string;
fn: (middlewareArguments: MiddlewareArguments) => MiddlewareReturn | Promise<MiddlewareReturn>;
options?: any;
fn: (middlewareArguments: MiddlewareArguments) => Promisable<MiddlewareReturn>;
};
export declare type Dimensions = {
width: number;
height: number;
[key in Length]: number;
};

@@ -155,1 +155,2 @@ export declare type Rect = Coords & Dimensions;

export { size } from './middleware/size';
export { inline } from './middleware/inline';

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