🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@floating-ui/core

Package Overview
Dependencies
Maintainers
2
Versions
59
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

to
1.0.5

190

dist/floating-ui.core.esm.js

@@ -30,3 +30,2 @@ function getSide(placement) {

let coords;
switch (side) {

@@ -39,3 +38,2 @@ case 'top':

break;
case 'bottom':

@@ -47,3 +45,2 @@ coords = {

break;
case 'right':

@@ -55,3 +52,2 @@ coords = {

break;
case 'left':

@@ -63,3 +59,2 @@ coords = {

break;
default:

@@ -71,3 +66,2 @@ coords = {

}
switch (getAlignment(placement)) {

@@ -77,3 +71,2 @@ case 'start':

break;
case 'end':

@@ -83,3 +76,2 @@ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);

}
return coords;

@@ -95,3 +87,2 @@ }

*/
const computePosition = async (reference, floating, config) => {

@@ -106,3 +97,2 @@ const {

const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
if (process.env.NODE_ENV !== "production") {

@@ -112,3 +102,2 @@ if (platform == null) {

}
if (validMiddleware.filter(_ref => {

@@ -122,3 +111,2 @@ let {

}
if (!reference || !floating) {

@@ -128,3 +116,2 @@ console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));

}
let rects = await platform.getElementRects({

@@ -142,3 +129,2 @@ reference,

let resetCount = 0;
for (let i = 0; i < validMiddleware.length; i++) {

@@ -170,8 +156,9 @@ const {

y = nextY != null ? nextY : y;
middlewareData = { ...middlewareData,
[name]: { ...middlewareData[name],
middlewareData = {
...middlewareData,
[name]: {
...middlewareData[name],
...data
}
};
if (process.env.NODE_ENV !== "production") {

@@ -182,6 +169,4 @@ if (resetCount > 50) {

}
if (reset && resetCount <= 50) {
resetCount++;
if (typeof reset === 'object') {

@@ -191,3 +176,2 @@ if (reset.placement) {

}
if (reset.rects) {

@@ -200,3 +184,2 @@ rects = reset.rects === true ? await platform.getElementRects({

}
({

@@ -207,3 +190,2 @@ x,

}
i = -1;

@@ -213,3 +195,2 @@ continue;

}
return {

@@ -244,3 +225,4 @@ x,

function rectToClientRect(rect) {
return { ...rect,
return {
...rect,
top: rect.y,

@@ -263,7 +245,5 @@ left: rect.x,

var _await$platform$isEle;
if (options === void 0) {
options = {};
}
const {

@@ -293,3 +273,4 @@ x,

}));
const rect = elementContext === 'floating' ? { ...rects.floating,
const rect = elementContext === 'floating' ? {
...rects.floating,
x,

@@ -311,5 +292,3 @@ y

}) : rect);
if (process.env.NODE_ENV !== "production") ;
return {

@@ -338,3 +317,2 @@ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,

options,
async fn(middlewareArguments) {

@@ -353,3 +331,2 @@ // Since `element` is required, we don't Partial<> the type

} = middlewareArguments;
if (element == null) {

@@ -359,6 +336,4 @@ if (process.env.NODE_ENV !== "production") {

}
return {};
}
const paddingObject = getSideObjectFromPadding(padding);

@@ -370,3 +345,2 @@ const coords = {

const axis = getMainAxisFromPlacement(placement);
const alignment = getAlignment(placement);
const length = getLengthFromAxis(axis);

@@ -380,17 +354,19 @@ const arrowDimensions = await platform.getDimensions(element);

let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
if (clientSize === 0) {
clientSize = rects.floating[length];
}
const centerToReference = endDiff / 2 - startDiff / 2;
const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
// Make sure the arrow doesn't overflow the floating element if the center
// point is outside the floating element's bounds
const min = paddingObject[minProp];
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = within(min, center, max); // Make sure that arrow points at the reference
const offset = within(min, center, max);
const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
// If the reference is small enough that the arrow's padding causes it to
// to point to nothing for an aligned placement, adjust the offset of the
// floating element itself. This stops `shift()` from taking action, but can
// be worked around by calling it again after the `arrow()` if desired.
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;

@@ -405,3 +381,2 @@ return {

}
});

@@ -423,3 +398,2 @@

}
const alignment = getAlignment(placement);

@@ -429,7 +403,5 @@ const mainAxis = getMainAxisFromPlacement(placement);

let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
if (rects.reference[length] > rects.floating[length]) {
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
}
return {

@@ -458,7 +430,5 @@ main: mainAlignmentSide,

}
return true;
});
}
/**

@@ -472,10 +442,7 @@ * Automatically chooses the `placement` which has the most space available.

}
return {
name: 'autoPlacement',
options,
async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;
const {

@@ -491,3 +458,3 @@ x,

const {
alignment = null,
alignment,
allowedPlacements = allPlacements,

@@ -497,16 +464,15 @@ autoAlignment = true,

} = options;
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
const currentPlacement = placements[currentIndex];
if (currentPlacement == null) {
return {};
}
const {
main,
cross
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
// Make `computeCoords` start from the right place
if (placement !== currentPlacement) {

@@ -521,3 +487,2 @@ return {

}
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];

@@ -528,4 +493,5 @@ const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {

}];
const nextPlacement = placements[currentIndex + 1]; // There are more placements to check
const nextPlacement = placements[currentIndex + 1];
// There are more placements to check
if (nextPlacement) {

@@ -542,3 +508,2 @@ return {

}
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);

@@ -552,3 +517,2 @@ const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {

const resetPlacement = placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement;
if (resetPlacement !== placement) {

@@ -565,6 +529,4 @@ return {

}
return {};
}
};

@@ -587,10 +549,7 @@ };

}
return {
name: 'flip',
options,
async fn(middlewareArguments) {
var _middlewareData$flip;
const {

@@ -619,7 +578,5 @@ placement,

let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
if (checkMainAxis) {
overflows.push(overflow[side]);
}
if (checkCrossAxis) {

@@ -632,14 +589,12 @@ const {

}
overflowsData = [...overflowsData, {
placement,
overflows
}]; // One or more sides is overflowing
}];
// One or more sides is overflowing
if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip2;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];
if (nextPlacement) {

@@ -657,5 +612,3 @@ // Try next placement and re-run the lifecycle

}
let resetPlacement = 'bottom';
switch (fallbackStrategy) {

@@ -665,12 +618,8 @@ case 'bestFit':

var _overflowsData$map$so;
const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
if (placement) {
resetPlacement = placement;
}
break;
}
case 'initialPlacement':

@@ -680,3 +629,2 @@ resetPlacement = initialPlacement;

}
if (placement !== resetPlacement) {

@@ -690,6 +638,4 @@ return {

}
return {};
}
};

@@ -706,7 +652,5 @@ };

}
function isAnySideFullyClipped(overflow) {
return sides.some(side => overflow[side] >= 0);
}
/**

@@ -717,19 +661,22 @@ * Provides data to hide the floating element in applicable situations, such as

*/
const hide = function (_temp) {
let {
strategy = 'referenceHidden',
...detectOverflowOptions
} = _temp === void 0 ? {} : _temp;
const hide = function (options) {
if (options === void 0) {
options = {};
}
return {
name: 'hide',
options,
async fn(middlewareArguments) {
const {
strategy = 'referenceHidden',
...detectOverflowOptions
} = options;
const {
rects
} = middlewareArguments;
switch (strategy) {
case 'referenceHidden':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
const overflow = await detectOverflow(middlewareArguments, {
...detectOverflowOptions,
elementContext: 'reference'

@@ -745,6 +692,6 @@ });

}
case 'escaped':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
const overflow = await detectOverflow(middlewareArguments, {
...detectOverflowOptions,
altBoundary: true

@@ -760,3 +707,2 @@ });

}
default:

@@ -768,3 +714,2 @@ {

}
};

@@ -785,4 +730,5 @@ };

const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
// eslint-disable-next-line prefer-const
let {

@@ -802,7 +748,5 @@ mainAxis,

};
if (alignment && typeof alignmentAxis === 'number') {
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
}
return isVertical ? {

@@ -816,2 +760,3 @@ x: crossAxis * crossAxisMulti,

}
/**

@@ -821,3 +766,2 @@ * Displaces the floating element from its reference element.

*/
const offset = function (value) {

@@ -827,7 +771,5 @@ if (value === void 0) {

}
return {
name: 'offset',
options: value,
async fn(middlewareArguments) {

@@ -845,3 +787,2 @@ const {

}
};

@@ -863,7 +804,5 @@ };

}
return {
name: 'shift',
options,
async fn(middlewareArguments) {

@@ -901,3 +840,2 @@ const {

let crossAxisCoord = coords[crossAxis];
if (checkMainAxis) {

@@ -910,3 +848,2 @@ const minSide = mainAxis === 'y' ? 'top' : 'left';

}
if (checkCrossAxis) {

@@ -919,8 +856,9 @@ const minSide = crossAxis === 'y' ? 'top' : 'left';

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

@@ -932,6 +870,4 @@ x: limitedCoords.x - x,

}
};
};
/**

@@ -944,6 +880,4 @@ * Built-in `limiter` that will stop `shift()` at a certain point.

}
return {
options,
fn(middlewareArguments) {

@@ -979,3 +913,2 @@ const {

};
if (checkMainAxis) {

@@ -985,3 +918,2 @@ const len = mainAxis === 'y' ? 'height' : 'width';

const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
if (mainAxisCoord < limitMin) {

@@ -993,6 +925,4 @@ mainAxisCoord = limitMin;

}
if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
const len = mainAxis === 'y' ? 'width' : 'height';

@@ -1002,3 +932,2 @@ const isOriginSide = ['top', 'left'].includes(getSide(placement));

const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : (_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[crossAxis]) != null ? _middlewareData$offse3 : 0) - (isOriginSide ? computedOffset.crossAxis : 0);
if (crossAxisCoord < limitMin) {

@@ -1010,3 +939,2 @@ crossAxisCoord = limitMin;

}
return {

@@ -1017,3 +945,2 @@ [mainAxis]: mainAxisCoord,

}
};

@@ -1032,7 +959,5 @@ };

}
return {
name: 'size',
options,
async fn(middlewareArguments) {

@@ -1054,3 +979,2 @@ const {

let widthSide;
if (side === 'top' || side === 'bottom') {

@@ -1063,3 +987,2 @@ heightSide = side;

}
const xMin = max(overflow.left, 0);

@@ -1073,7 +996,7 @@ const xMax = max(overflow.right, 0);

};
await apply({ ...middlewareArguments,
await apply({
...middlewareArguments,
...dimensions
});
const nextDimensions = await platform.getDimensions(elements.floating);
if (rects.floating.width !== nextDimensions.width || rects.floating.height !== nextDimensions.height) {

@@ -1086,6 +1009,4 @@ return {

}
return {};
}
};

@@ -1103,10 +1024,7 @@ };

}
return {
name: 'inline',
options,
async fn(middlewareArguments) {
var _await$platform$getCl;
const {

@@ -1118,6 +1036,6 @@ placement,

strategy
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
} = 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 {

@@ -1135,3 +1053,2 @@ padding = 2,

const paddingObject = getSideObjectFromPadding(padding);
function getBoundingClientRect() {

@@ -1141,8 +1058,7 @@ // There are two rects and they are disjoined

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
}
// There are 2 or more connected rects
if (clientRects.length >= 2) {

@@ -1170,3 +1086,2 @@ if (getMainAxisFromPlacement(placement) === 'x') {

}
const isLeftSide = getSide(placement) === 'left';

@@ -1193,6 +1108,4 @@ const maxRight = max(...clientRects.map(rect => rect.right));

}
return fallback;
}
const resetRects = await platform.getElementRects({

@@ -1205,3 +1118,2 @@ reference: {

});
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {

@@ -1214,6 +1126,4 @@ return {

}
return {};
}
};

@@ -1220,0 +1130,0 @@ };

@@ -36,3 +36,2 @@ (function (global, factory) {

let coords;
switch (side) {

@@ -45,3 +44,2 @@ case 'top':

break;
case 'bottom':

@@ -53,3 +51,2 @@ coords = {

break;
case 'right':

@@ -61,3 +58,2 @@ coords = {

break;
case 'left':

@@ -69,3 +65,2 @@ coords = {

break;
default:

@@ -77,3 +72,2 @@ coords = {

}
switch (getAlignment(placement)) {

@@ -83,3 +77,2 @@ case 'start':

break;
case 'end':

@@ -89,3 +82,2 @@ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);

}
return coords;

@@ -101,3 +93,2 @@ }

*/
const computePosition = async (reference, floating, config) => {

@@ -112,3 +103,2 @@ const {

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

@@ -118,3 +108,2 @@ if (platform == null) {

}
if (validMiddleware.filter(_ref => {

@@ -128,3 +117,2 @@ let {

}
if (!reference || !floating) {

@@ -134,3 +122,2 @@ console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));

}
let rects = await platform.getElementRects({

@@ -148,3 +135,2 @@ reference,

let resetCount = 0;
for (let i = 0; i < validMiddleware.length; i++) {

@@ -176,8 +162,9 @@ const {

y = nextY != null ? nextY : y;
middlewareData = { ...middlewareData,
[name]: { ...middlewareData[name],
middlewareData = {
...middlewareData,
[name]: {
...middlewareData[name],
...data
}
};
{

@@ -188,6 +175,4 @@ if (resetCount > 50) {

}
if (reset && resetCount <= 50) {
resetCount++;
if (typeof reset === 'object') {

@@ -197,3 +182,2 @@ if (reset.placement) {

}
if (reset.rects) {

@@ -206,3 +190,2 @@ rects = reset.rects === true ? await platform.getElementRects({

}
({

@@ -213,3 +196,2 @@ x,

}
i = -1;

@@ -219,3 +201,2 @@ continue;

}
return {

@@ -250,3 +231,4 @@ x,

function rectToClientRect(rect) {
return { ...rect,
return {
...rect,
top: rect.y,

@@ -269,7 +251,5 @@ left: rect.x,

var _await$platform$isEle;
if (options === void 0) {
options = {};
}
const {

@@ -299,3 +279,4 @@ x,

}));
const rect = elementContext === 'floating' ? { ...rects.floating,
const rect = elementContext === 'floating' ? {
...rects.floating,
x,

@@ -317,3 +298,2 @@ y

}) : rect);
return {

@@ -342,3 +322,2 @@ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,

options,
async fn(middlewareArguments) {

@@ -357,3 +336,2 @@ // Since `element` is required, we don't Partial<> the type

} = middlewareArguments;
if (element == null) {

@@ -363,6 +341,4 @@ {

}
return {};
}
const paddingObject = getSideObjectFromPadding(padding);

@@ -374,3 +350,2 @@ const coords = {

const axis = getMainAxisFromPlacement(placement);
const alignment = getAlignment(placement);
const length = getLengthFromAxis(axis);

@@ -384,17 +359,19 @@ const arrowDimensions = await platform.getDimensions(element);

let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
if (clientSize === 0) {
clientSize = rects.floating[length];
}
const centerToReference = endDiff / 2 - startDiff / 2;
const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
// Make sure the arrow doesn't overflow the floating element if the center
// point is outside the floating element's bounds
const min = paddingObject[minProp];
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = within(min, center, max); // Make sure that arrow points at the reference
const offset = within(min, center, max);
const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
// If the reference is small enough that the arrow's padding causes it to
// to point to nothing for an aligned placement, adjust the offset of the
// floating element itself. This stops `shift()` from taking action, but can
// be worked around by calling it again after the `arrow()` if desired.
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;

@@ -409,3 +386,2 @@ return {

}
});

@@ -427,3 +403,2 @@

}
const alignment = getAlignment(placement);

@@ -433,7 +408,5 @@ const mainAxis = getMainAxisFromPlacement(placement);

let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
if (rects.reference[length] > rects.floating[length]) {
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
}
return {

@@ -462,7 +435,5 @@ main: mainAlignmentSide,

}
return true;
});
}
/**

@@ -476,10 +447,7 @@ * Automatically chooses the `placement` which has the most space available.

}
return {
name: 'autoPlacement',
options,
async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;
const {

@@ -495,3 +463,3 @@ x,

const {
alignment = null,
alignment,
allowedPlacements = allPlacements,

@@ -501,16 +469,15 @@ autoAlignment = true,

} = options;
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
const currentPlacement = placements[currentIndex];
if (currentPlacement == null) {
return {};
}
const {
main,
cross
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
// Make `computeCoords` start from the right place
if (placement !== currentPlacement) {

@@ -525,3 +492,2 @@ return {

}
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];

@@ -532,4 +498,5 @@ const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {

}];
const nextPlacement = placements[currentIndex + 1]; // There are more placements to check
const nextPlacement = placements[currentIndex + 1];
// There are more placements to check
if (nextPlacement) {

@@ -546,3 +513,2 @@ return {

}
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);

@@ -556,3 +522,2 @@ const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {

const resetPlacement = placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement;
if (resetPlacement !== placement) {

@@ -569,6 +534,4 @@ return {

}
return {};
}
};

@@ -591,10 +554,7 @@ };

}
return {
name: 'flip',
options,
async fn(middlewareArguments) {
var _middlewareData$flip;
const {

@@ -623,7 +583,5 @@ placement,

let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
if (checkMainAxis) {
overflows.push(overflow[side]);
}
if (checkCrossAxis) {

@@ -636,14 +594,12 @@ const {

}
overflowsData = [...overflowsData, {
placement,
overflows
}]; // One or more sides is overflowing
}];
// One or more sides is overflowing
if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip2;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];
if (nextPlacement) {

@@ -661,5 +617,3 @@ // Try next placement and re-run the lifecycle

}
let resetPlacement = 'bottom';
switch (fallbackStrategy) {

@@ -669,12 +623,8 @@ case 'bestFit':

var _overflowsData$map$so;
const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
if (placement) {
resetPlacement = placement;
}
break;
}
case 'initialPlacement':

@@ -684,3 +634,2 @@ resetPlacement = initialPlacement;

}
if (placement !== resetPlacement) {

@@ -694,6 +643,4 @@ return {

}
return {};
}
};

@@ -710,7 +657,5 @@ };

}
function isAnySideFullyClipped(overflow) {
return sides.some(side => overflow[side] >= 0);
}
/**

@@ -721,19 +666,22 @@ * Provides data to hide the floating element in applicable situations, such as

*/
const hide = function (_temp) {
let {
strategy = 'referenceHidden',
...detectOverflowOptions
} = _temp === void 0 ? {} : _temp;
const hide = function (options) {
if (options === void 0) {
options = {};
}
return {
name: 'hide',
options,
async fn(middlewareArguments) {
const {
strategy = 'referenceHidden',
...detectOverflowOptions
} = options;
const {
rects
} = middlewareArguments;
switch (strategy) {
case 'referenceHidden':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
const overflow = await detectOverflow(middlewareArguments, {
...detectOverflowOptions,
elementContext: 'reference'

@@ -749,6 +697,6 @@ });

}
case 'escaped':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
const overflow = await detectOverflow(middlewareArguments, {
...detectOverflowOptions,
altBoundary: true

@@ -764,3 +712,2 @@ });

}
default:

@@ -772,3 +719,2 @@ {

}
};

@@ -789,4 +735,5 @@ };

const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value;
// eslint-disable-next-line prefer-const
let {

@@ -806,7 +753,5 @@ mainAxis,

};
if (alignment && typeof alignmentAxis === 'number') {
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
}
return isVertical ? {

@@ -820,2 +765,3 @@ x: crossAxis * crossAxisMulti,

}
/**

@@ -825,3 +771,2 @@ * Displaces the floating element from its reference element.

*/
const offset = function (value) {

@@ -831,7 +776,5 @@ if (value === void 0) {

}
return {
name: 'offset',
options: value,
async fn(middlewareArguments) {

@@ -849,3 +792,2 @@ const {

}
};

@@ -867,7 +809,5 @@ };

}
return {
name: 'shift',
options,
async fn(middlewareArguments) {

@@ -905,3 +845,2 @@ const {

let crossAxisCoord = coords[crossAxis];
if (checkMainAxis) {

@@ -914,3 +853,2 @@ const minSide = mainAxis === 'y' ? 'top' : 'left';

}
if (checkCrossAxis) {

@@ -923,8 +861,9 @@ const minSide = crossAxis === 'y' ? 'top' : 'left';

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

@@ -936,6 +875,4 @@ x: limitedCoords.x - x,

}
};
};
/**

@@ -948,6 +885,4 @@ * Built-in `limiter` that will stop `shift()` at a certain point.

}
return {
options,
fn(middlewareArguments) {

@@ -983,3 +918,2 @@ const {

};
if (checkMainAxis) {

@@ -989,3 +923,2 @@ const len = mainAxis === 'y' ? 'height' : 'width';

const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
if (mainAxisCoord < limitMin) {

@@ -997,6 +930,4 @@ mainAxisCoord = limitMin;

}
if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
const len = mainAxis === 'y' ? 'width' : 'height';

@@ -1006,3 +937,2 @@ const isOriginSide = ['top', 'left'].includes(getSide(placement));

const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : (_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[crossAxis]) != null ? _middlewareData$offse3 : 0) - (isOriginSide ? computedOffset.crossAxis : 0);
if (crossAxisCoord < limitMin) {

@@ -1014,3 +944,2 @@ crossAxisCoord = limitMin;

}
return {

@@ -1021,3 +950,2 @@ [mainAxis]: mainAxisCoord,

}
};

@@ -1036,7 +964,5 @@ };

}
return {
name: 'size',
options,
async fn(middlewareArguments) {

@@ -1058,3 +984,2 @@ const {

let widthSide;
if (side === 'top' || side === 'bottom') {

@@ -1067,3 +992,2 @@ heightSide = side;

}
const xMin = max(overflow.left, 0);

@@ -1077,7 +1001,7 @@ const xMax = max(overflow.right, 0);

};
await apply({ ...middlewareArguments,
await apply({
...middlewareArguments,
...dimensions
});
const nextDimensions = await platform.getDimensions(elements.floating);
if (rects.floating.width !== nextDimensions.width || rects.floating.height !== nextDimensions.height) {

@@ -1090,6 +1014,4 @@ return {

}
return {};
}
};

@@ -1107,10 +1029,7 @@ };

}
return {
name: 'inline',
options,
async fn(middlewareArguments) {
var _await$platform$getCl;
const {

@@ -1122,6 +1041,6 @@ placement,

strategy
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
} = 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 {

@@ -1139,3 +1058,2 @@ padding = 2,

const paddingObject = getSideObjectFromPadding(padding);
function getBoundingClientRect() {

@@ -1145,8 +1063,7 @@ // There are two rects and they are disjoined

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
}
// There are 2 or more connected rects
if (clientRects.length >= 2) {

@@ -1174,3 +1091,2 @@ if (getMainAxisFromPlacement(placement) === 'x') {

}
const isLeftSide = getSide(placement) === 'left';

@@ -1197,6 +1113,4 @@ const maxRight = max(...clientRects.map(rect => rect.right));

}
return fallback;
}
const resetRects = await platform.getElementRects({

@@ -1209,3 +1123,2 @@ reference: {

});
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {

@@ -1218,6 +1131,4 @@ return {

}
return {};
}
};

@@ -1224,0 +1135,0 @@ };

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

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

@@ -40,3 +40,2 @@ ]

],
"browserslist": "> 0.5%, not dead, not IE 11",
"scripts": {

@@ -63,17 +62,3 @@ "test": "jest test",

"positioning"
],
"devDependencies": {
"@atomico/rollup-plugin-sizes": "^1.1.4",
"@babel/preset-env": "^7.16.4",
"@babel/preset-typescript": "^7.16.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^3.0.0",
"@types/jest": "^27.0.3",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"jest": "^27.3.1",
"rollup": "^2.60.1",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^27.0.7"
}
]
}

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

* Choose placements with a particular alignment.
* @default null
* @default undefined
*/

@@ -10,0 +10,0 @@ alignment: Alignment | null;

@@ -11,2 +11,2 @@ import type { Middleware } from '../types';

*/
export declare const hide: ({ strategy, ...detectOverflowOptions }?: Partial<Options & DetectOverflowOptions>) => Middleware;
export declare const hide: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
import type { Coords, Middleware, MiddlewareArguments } from '../types';
declare type OffsetValue = number | {
type OffsetValue = number | {
/**

@@ -22,4 +22,4 @@ * The axis that runs along the side of the floating element.

};
declare type OffsetFunction = (args: MiddlewareArguments) => OffsetValue;
export declare type Options = OffsetValue | OffsetFunction;
type OffsetFunction = (args: MiddlewareArguments) => OffsetValue;
export type Options = OffsetValue | OffsetFunction;
export declare function convertValueToCoords(middlewareArguments: MiddlewareArguments, value: Options): Promise<Coords>;

@@ -26,0 +26,0 @@ /**

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

export declare const shift: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
declare type LimitShiftOffset = ((args: MiddlewareArguments) => number | {
type LimitShiftOffset = ((args: MiddlewareArguments) => number | {
/**

@@ -53,3 +53,3 @@ * Offset the limiting of the axis that runs along the alignment of the

};
export declare type LimitShiftOptions = {
export type LimitShiftOptions = {
/**

@@ -56,0 +56,0 @@ * Offset when limiting starts. `0` will limit when the opposite edges of the

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

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

@@ -41,6 +41,6 @@ * Platform interface methods to work with the current platform.

}
export declare type Coords = {
export type Coords = {
[key in Axis]: number;
};
export declare type SideObject = {
export type SideObject = {
[key in Side]: number;

@@ -87,3 +87,3 @@ };

}
export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
export type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
export interface MiddlewareReturn extends Partial<Coords> {

@@ -98,3 +98,3 @@ data?: {

}
export declare type Middleware = {
export type Middleware = {
name: string;

@@ -104,6 +104,6 @@ options?: any;

};
export declare type Dimensions = {
export type Dimensions = {
[key in Length]: number;
};
export declare type Rect = Coords & Dimensions;
export type Rect = Coords & Dimensions;
export interface ElementRects {

@@ -117,8 +117,8 @@ reference: Rect;

*/
export declare type VirtualElement = {
export type VirtualElement = {
getBoundingClientRect(): ClientRectObject;
contextElement?: any;
};
export declare type ReferenceElement = any;
export declare type FloatingElement = any;
export type ReferenceElement = any;
export type FloatingElement = any;
export interface Elements {

@@ -137,7 +137,7 @@ reference: ReferenceElement;

}
export declare type ClientRectObject = Rect & SideObject;
export declare type Padding = number | Partial<SideObject>;
export declare type Boundary = any;
export declare type RootBoundary = 'viewport' | 'document';
export declare type ElementContext = 'reference' | 'floating';
export type ClientRectObject = Rect & SideObject;
export type Padding = number | Partial<SideObject>;
export type Boundary = any;
export type RootBoundary = 'viewport' | 'document';
export type ElementContext = 'reference' | 'floating';
export { computePosition } from './computePosition';

@@ -144,0 +144,0 @@ export { rectToClientRect } from './utils/rectToClientRect';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet