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.4.0 to 0.5.0

src/utils/getSide.d.ts

322

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

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

function getBasePlacement(placement) {
function getSide(placement) {
return placement.split('-')[0];

@@ -10,3 +10,3 @@ }

function getMainAxisFromPlacement(placement) {
return ['top', 'bottom'].includes(getBasePlacement(placement)) ? 'x' : 'y';
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
}

@@ -22,9 +22,15 @@

floating,
placement
placement,
rtl = false
} = _ref;
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
const commonAlign = reference[length] / 2 - floating[length] / 2;
const side = getSide(placement);
const isVertical = mainAxis === 'x';
let coords;
switch (getBasePlacement(placement)) {
switch (side) {
case 'top':

@@ -65,12 +71,9 @@ coords = {

const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
switch (getAlignment(placement)) {
case 'start':
coords[mainAxis] = coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[mainAxis] = coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;

@@ -97,2 +100,3 @@ }

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

@@ -123,6 +127,8 @@ {

} = computeCoordsFromPlacement({ ...rects,
placement
placement,
rtl
});
let statefulPlacement = placement;
let middlewareData = {};
const skippedMiddlewareNames = new Set();
let _debug_loop_count_ = 0;

@@ -143,2 +149,7 @@

} = middleware[i];
if (skippedMiddlewareNames.has(name)) {
continue;
}
const {

@@ -166,3 +177,5 @@ x: nextX,

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

@@ -188,4 +201,9 @@

} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
placement: statefulPlacement,
rtl
}));
if (reset.skip !== false) {
skippedMiddlewareNames.add(name);
}
}

@@ -241,4 +259,7 @@

* - 0 = lies flush with the boundary
* @see https://floating-ui.com/docs/detectOverflow
*/
async function detectOverflow(middlewareArguments, options) {
var _await$platform$isEle;
if (options === void 0) {

@@ -257,3 +278,3 @@ options = {};

const {
boundary = 'clippingParents',
boundary = 'clippingAncestors',
rootBoundary = 'viewport',

@@ -267,10 +288,8 @@ elementContext = 'floating',

const element = elements[altBoundary ? altContext : elementContext];
const clippingClientRect = await platform.getClippingClientRect({
element: (await platform.isElement(element)) ? element : element.contextElement || (await platform.getDocumentElement({
element: elements.floating
})),
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
boundary,
rootBoundary
});
const elementClientRect = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
}));
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: elementContext === 'floating' ? { ...rects.floating,

@@ -280,7 +299,5 @@ x,

} : rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
strategy
})); // positive = overflowing the clipping rect
}) : rects[elementContext]); // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect

@@ -306,2 +323,3 @@

* to the reference element.
* @see https://floating-ui.com/docs/arrow
*/

@@ -339,8 +357,5 @@ const arrow = options => ({

};
const basePlacement = getBasePlacement(placement);
const axis = getMainAxisFromPlacement(basePlacement);
const axis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(axis);
const arrowDimensions = await platform.getDimensions({
element
});
const arrowDimensions = await platform.getDimensions(element);
const minProp = axis === 'y' ? 'top' : 'left';

@@ -350,5 +365,3 @@ const maxProp = axis === 'y' ? 'bottom' : 'right';

const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = await platform.getOffsetParent({
element
});
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;

@@ -382,7 +395,11 @@ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center

function getAlignmentSides(placement, rects) {
const isStart = getAlignment(placement) === 'start';
function getAlignmentSides(placement, rects, rtl) {
if (rtl === void 0) {
rtl = false;
}
const alignment = getAlignment(placement);
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
let mainAlignmentSide = mainAxis === 'x' ? isStart ? 'right' : 'left' : isStart ? 'bottom' : 'top';
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';

@@ -407,7 +424,7 @@ if (rects.reference[length] > rects.floating[length]) {

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

@@ -424,2 +441,3 @@ if (alignment) {

* Automatically chooses the `placement` which has the most space available.
* @see https://floating-ui.com/docs/autoPlacement
*/

@@ -436,3 +454,3 @@ const autoPlacement = function (options) {

async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;

@@ -444,3 +462,5 @@ const {

middlewareData,
placement
placement,
platform,
elements
} = middlewareArguments;

@@ -453,10 +473,5 @@ const {

} = options;
if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {
return {};
}
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;
const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
const currentPlacement = placements[currentIndex];

@@ -466,3 +481,3 @@ const {

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

@@ -474,2 +489,3 @@ if (placement !== currentPlacement) {

reset: {
skip: false,
placement: placements[0]

@@ -480,4 +496,4 @@ }

const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...((_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : []), {
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {
placement: currentPlacement,

@@ -495,2 +511,3 @@ overflows: currentOverflows

reset: {
skip: false,
placement: nextPlacement

@@ -509,5 +526,2 @@ }

return {
data: {
skip: true
},
reset: {

@@ -530,2 +544,3 @@ placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement

* initially specified `placement` does not.
* @see https://floating-ui.com/docs/flip
*/

@@ -542,3 +557,3 @@ const flip = function (options) {

async fn(middlewareArguments) {
var _middlewareData$flip, _middlewareData$flip2;
var _middlewareData$flip;

@@ -549,9 +564,6 @@ const {

rects,
initialPlacement
initialPlacement,
platform,
elements
} = middlewareArguments;
if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {
return {};
}
const {

@@ -565,4 +577,4 @@ mainAxis: checkMainAxis = true,

} = options;
const basePlacement = getBasePlacement(placement);
const isBasePlacement = basePlacement === initialPlacement;
const side = getSide(placement);
const isBasePlacement = side === initialPlacement;
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));

@@ -572,6 +584,6 @@ const placements = [initialPlacement, ...fallbackPlacements];

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

@@ -583,3 +595,3 @@

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

@@ -594,5 +606,5 @@ }

if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip3;
var _middlewareData$flip$, _middlewareData$flip2;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];

@@ -608,2 +620,3 @@

reset: {
skip: false,
placement: nextPlacement

@@ -636,5 +649,2 @@ }

return {
data: {
skip: true
},
reset: {

@@ -662,35 +672,61 @@ placement: resetPlacement

function isAnySideFullyClipped(overflow) {
return basePlacements.some(side => overflow[side] >= 0);
return sides.some(side => overflow[side] >= 0);
}
/**
* Provides data to hide the floating element in applicable situations, such as
* when it is not in the same clipping context as the reference element.
* @see https://floating-ui.com/docs/hide
*/
const hide = function (_temp) {
let {
strategy = 'referenceHidden',
...detectOverflowOptions
} = _temp === void 0 ? {} : _temp;
return {
name: 'hide',
async fn(middlewareArguments) {
const {
rects
} = middlewareArguments;
const hide = () => ({
name: 'hide',
switch (strategy) {
case 'referenceHidden':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
elementContext: 'reference'
});
const offsets = getSideOffsets(overflow, rects.reference);
return {
data: {
referenceHiddenOffsets: offsets,
referenceHidden: isAnySideFullyClipped(offsets)
}
};
}
async fn(modifierArguments) {
const referenceOverflow = await detectOverflow(modifierArguments, {
elementContext: 'reference'
});
const floatingAltOverflow = await detectOverflow(modifierArguments, {
altBoundary: true
});
const referenceHiddenOffsets = getSideOffsets(referenceOverflow, modifierArguments.rects.reference);
const escapedOffsets = getSideOffsets(floatingAltOverflow, modifierArguments.rects.floating);
const referenceHidden = isAnySideFullyClipped(referenceHiddenOffsets);
const escaped = isAnySideFullyClipped(escapedOffsets);
return {
data: {
referenceHidden,
referenceHiddenOffsets,
escaped,
escapedOffsets
case 'escaped':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
altBoundary: true
});
const offsets = getSideOffsets(overflow, rects.floating);
return {
data: {
escapedOffsets: offsets,
escaped: isAnySideFullyClipped(offsets)
}
};
}
default:
{
return {};
}
}
};
}
}
});
};
};

@@ -701,6 +737,19 @@ function convertValueToCoords(_ref) {

rects,
value
value,
rtl = false
} = _ref;
const basePlacement = getBasePlacement(placement);
const multiplier = ['left', 'top'].includes(basePlacement) ? -1 : 1;
const side = getSide(placement);
const alignment = getAlignment(placement);
const isVertical = getMainAxisFromPlacement(placement) === 'x';
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
let crossAxisMulti = 1;
if (alignment === 'end') {
crossAxisMulti = -1;
}
if (rtl && isVertical) {
crossAxisMulti *= -1;
}
const rawValue = typeof value === 'function' ? value({ ...rects,

@@ -720,8 +769,8 @@ placement

};
return getMainAxisFromPlacement(basePlacement) === 'x' ? {
x: crossAxis,
y: mainAxis * multiplier
return isVertical ? {
x: crossAxis * crossAxisMulti,
y: mainAxis * mainAxisMulti
} : {
x: mainAxis * multiplier,
y: crossAxis
x: mainAxis * mainAxisMulti,
y: crossAxis * crossAxisMulti
};

@@ -731,2 +780,3 @@ }

* Displaces the floating element from its reference element.
* @see https://floating-ui.com/docs/offset
*/

@@ -743,3 +793,3 @@

fn(middlewareArguments) {
async fn(middlewareArguments) {
const {

@@ -749,3 +799,5 @@ x,

placement,
rects
rects,
platform,
elements
} = middlewareArguments;

@@ -755,3 +807,4 @@ const diffCoords = convertValueToCoords({

rects,
value
value,
rtl: await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))
});

@@ -775,2 +828,3 @@ return {

* a clipping boundary.
* @see https://floating-ui.com/docs/shift
*/

@@ -814,3 +868,3 @@ const shift = function (options) {

const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const mainAxis = getMainAxisFromPlacement(getSide(placement));
const crossAxis = getCrossAxis(mainAxis);

@@ -911,3 +965,3 @@ let mainAxisCoord = coords[mainAxis];

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

@@ -936,2 +990,3 @@ 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);

* reference element.
* @see https://floating-ui.com/docs/size
*/

@@ -948,8 +1003,7 @@ const size = function (options) {

async fn(middlewareArguments) {
var _middlewareData$size;
const {
placement,
rects,
middlewareData
platform,
elements
} = middlewareArguments;

@@ -960,19 +1014,14 @@ const {

} = options;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const basePlacement = getBasePlacement(placement);
const isEnd = getAlignment(placement) === 'end';
const side = getSide(placement);
const alignment = getAlignment(placement);
let heightSide;
let widthSide;
if (basePlacement === 'top' || basePlacement === 'bottom') {
heightSide = basePlacement;
widthSide = isEnd ? 'left' : 'right';
if (side === 'top' || side === 'bottom') {
heightSide = side;
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))) ? 'start' : 'end') ? 'left' : 'right';
} else {
widthSide = basePlacement;
heightSide = isEnd ? 'top' : 'bottom';
widthSide = side;
heightSide = alignment === 'end' ? 'top' : 'bottom';
}

@@ -992,5 +1041,2 @@

return {
data: {
skip: true
},
reset: {

@@ -1008,2 +1054,3 @@ rects: true

* over multiple lines, such as hyperlinks or range selections.
* @see https://floating-ui.com/docs/inline
*/

@@ -1020,3 +1067,3 @@ const inline = function (options) {

async fn(middlewareArguments) {
var _middlewareData$inlin, _await$platform$getCl;
var _await$platform$getCl;

@@ -1028,4 +1075,3 @@ const {

platform,
strategy,
middlewareData
strategy
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a

@@ -1040,17 +1086,8 @@ // ClientRect's bounds, despite the event listener being triggered. A

} = options;
if ((_middlewareData$inlin = middlewareData.inline) != null && _middlewareData$inlin.skip) {
return {};
}
const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(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 : []);
}) : rects.reference);
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : []);
const paddingObject = getSideObjectFromPadding(padding);

@@ -1072,3 +1109,3 @@

const lastRect = clientRects[clientRects.length - 1];
const isTop = getBasePlacement(placement) === 'top';
const isTop = getSide(placement) === 'top';
const top = firstRect.top;

@@ -1092,6 +1129,6 @@ const bottom = lastRect.bottom;

const isLeftPlacement = getBasePlacement(placement) === 'left';
const isLeftSide = getSide(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 measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
const top = measureRects[0].top;

@@ -1119,5 +1156,2 @@ const bottom = measureRects[measureRects.length - 1].bottom;

return {
data: {
skip: true
},
reset: {

@@ -1124,0 +1158,0 @@ rects: await platform.getElementRects({

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

function getBasePlacement(placement) {
function getSide(placement) {
return placement.split('-')[0];

@@ -10,3 +10,3 @@ }

function getMainAxisFromPlacement(placement) {
return ['top', 'bottom'].includes(getBasePlacement(placement)) ? 'x' : 'y';
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
}

@@ -22,9 +22,15 @@

floating,
placement
placement,
rtl = false
} = _ref;
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
const commonAlign = reference[length] / 2 - floating[length] / 2;
const side = getSide(placement);
const isVertical = mainAxis === 'x';
let coords;
switch (getBasePlacement(placement)) {
switch (side) {
case 'top':

@@ -65,12 +71,9 @@ coords = {

const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
switch (getAlignment(placement)) {
case 'start':
coords[mainAxis] = coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[mainAxis] = coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;

@@ -97,2 +100,3 @@ }

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

@@ -123,6 +127,8 @@ if (process.env.NODE_ENV !== "production") {

} = computeCoordsFromPlacement({ ...rects,
placement
placement,
rtl
});
let statefulPlacement = placement;
let middlewareData = {};
const skippedMiddlewareNames = new Set();
let _debug_loop_count_ = 0;

@@ -143,2 +149,7 @@

} = middleware[i];
if (skippedMiddlewareNames.has(name)) {
continue;
}
const {

@@ -166,3 +177,5 @@ x: nextX,

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

@@ -188,4 +201,9 @@

} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
placement: statefulPlacement,
rtl
}));
if (reset.skip !== false) {
skippedMiddlewareNames.add(name);
}
}

@@ -241,4 +259,7 @@

* - 0 = lies flush with the boundary
* @see https://floating-ui.com/docs/detectOverflow
*/
async function detectOverflow(middlewareArguments, options) {
var _await$platform$isEle;
if (options === void 0) {

@@ -257,3 +278,3 @@ options = {};

const {
boundary = 'clippingParents',
boundary = 'clippingAncestors',
rootBoundary = 'viewport',

@@ -267,10 +288,8 @@ elementContext = 'floating',

const element = elements[altBoundary ? altContext : elementContext];
const clippingClientRect = await platform.getClippingClientRect({
element: (await platform.isElement(element)) ? element : element.contextElement || (await platform.getDocumentElement({
element: elements.floating
})),
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
boundary,
rootBoundary
});
const elementClientRect = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
}));
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: elementContext === 'floating' ? { ...rects.floating,

@@ -280,7 +299,5 @@ x,

} : rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
strategy
})); // positive = overflowing the clipping rect
}) : rects[elementContext]); // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect

@@ -306,2 +323,3 @@

* to the reference element.
* @see https://floating-ui.com/docs/arrow
*/

@@ -339,8 +357,5 @@ const arrow = options => ({

};
const basePlacement = getBasePlacement(placement);
const axis = getMainAxisFromPlacement(basePlacement);
const axis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(axis);
const arrowDimensions = await platform.getDimensions({
element
});
const arrowDimensions = await platform.getDimensions(element);
const minProp = axis === 'y' ? 'top' : 'left';

@@ -350,5 +365,3 @@ const maxProp = axis === 'y' ? 'bottom' : 'right';

const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = await platform.getOffsetParent({
element
});
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;

@@ -382,7 +395,11 @@ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center

function getAlignmentSides(placement, rects) {
const isStart = getAlignment(placement) === 'start';
function getAlignmentSides(placement, rects, rtl) {
if (rtl === void 0) {
rtl = false;
}
const alignment = getAlignment(placement);
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
let mainAlignmentSide = mainAxis === 'x' ? isStart ? 'right' : 'left' : isStart ? 'bottom' : 'top';
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';

@@ -407,7 +424,7 @@ if (rects.reference[length] > rects.floating[length]) {

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

@@ -424,2 +441,3 @@ if (alignment) {

* Automatically chooses the `placement` which has the most space available.
* @see https://floating-ui.com/docs/autoPlacement
*/

@@ -436,3 +454,3 @@ const autoPlacement = function (options) {

async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;

@@ -444,3 +462,5 @@ const {

middlewareData,
placement
placement,
platform,
elements
} = middlewareArguments;

@@ -453,10 +473,5 @@ const {

} = options;
if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {
return {};
}
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;
const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
const currentPlacement = placements[currentIndex];

@@ -466,3 +481,3 @@ const {

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

@@ -474,2 +489,3 @@ if (placement !== currentPlacement) {

reset: {
skip: false,
placement: placements[0]

@@ -480,4 +496,4 @@ }

const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...((_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : []), {
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {
placement: currentPlacement,

@@ -495,2 +511,3 @@ overflows: currentOverflows

reset: {
skip: false,
placement: nextPlacement

@@ -509,5 +526,2 @@ }

return {
data: {
skip: true
},
reset: {

@@ -530,2 +544,3 @@ placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement

* initially specified `placement` does not.
* @see https://floating-ui.com/docs/flip
*/

@@ -542,3 +557,3 @@ const flip = function (options) {

async fn(middlewareArguments) {
var _middlewareData$flip, _middlewareData$flip2;
var _middlewareData$flip;

@@ -549,9 +564,6 @@ const {

rects,
initialPlacement
initialPlacement,
platform,
elements
} = middlewareArguments;
if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {
return {};
}
const {

@@ -565,4 +577,4 @@ mainAxis: checkMainAxis = true,

} = options;
const basePlacement = getBasePlacement(placement);
const isBasePlacement = basePlacement === initialPlacement;
const side = getSide(placement);
const isBasePlacement = side === initialPlacement;
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));

@@ -572,6 +584,6 @@ const placements = [initialPlacement, ...fallbackPlacements];

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

@@ -583,3 +595,3 @@

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

@@ -594,5 +606,5 @@ }

if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip3;
var _middlewareData$flip$, _middlewareData$flip2;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];

@@ -608,2 +620,3 @@

reset: {
skip: false,
placement: nextPlacement

@@ -636,5 +649,2 @@ }

return {
data: {
skip: true
},
reset: {

@@ -662,35 +672,61 @@ placement: resetPlacement

function isAnySideFullyClipped(overflow) {
return basePlacements.some(side => overflow[side] >= 0);
return sides.some(side => overflow[side] >= 0);
}
/**
* Provides data to hide the floating element in applicable situations, such as
* when it is not in the same clipping context as the reference element.
* @see https://floating-ui.com/docs/hide
*/
const hide = function (_temp) {
let {
strategy = 'referenceHidden',
...detectOverflowOptions
} = _temp === void 0 ? {} : _temp;
return {
name: 'hide',
async fn(middlewareArguments) {
const {
rects
} = middlewareArguments;
const hide = () => ({
name: 'hide',
switch (strategy) {
case 'referenceHidden':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
elementContext: 'reference'
});
const offsets = getSideOffsets(overflow, rects.reference);
return {
data: {
referenceHiddenOffsets: offsets,
referenceHidden: isAnySideFullyClipped(offsets)
}
};
}
async fn(modifierArguments) {
const referenceOverflow = await detectOverflow(modifierArguments, {
elementContext: 'reference'
});
const floatingAltOverflow = await detectOverflow(modifierArguments, {
altBoundary: true
});
const referenceHiddenOffsets = getSideOffsets(referenceOverflow, modifierArguments.rects.reference);
const escapedOffsets = getSideOffsets(floatingAltOverflow, modifierArguments.rects.floating);
const referenceHidden = isAnySideFullyClipped(referenceHiddenOffsets);
const escaped = isAnySideFullyClipped(escapedOffsets);
return {
data: {
referenceHidden,
referenceHiddenOffsets,
escaped,
escapedOffsets
case 'escaped':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
altBoundary: true
});
const offsets = getSideOffsets(overflow, rects.floating);
return {
data: {
escapedOffsets: offsets,
escaped: isAnySideFullyClipped(offsets)
}
};
}
default:
{
return {};
}
}
};
}
}
});
};
};

@@ -701,6 +737,19 @@ function convertValueToCoords(_ref) {

rects,
value
value,
rtl = false
} = _ref;
const basePlacement = getBasePlacement(placement);
const multiplier = ['left', 'top'].includes(basePlacement) ? -1 : 1;
const side = getSide(placement);
const alignment = getAlignment(placement);
const isVertical = getMainAxisFromPlacement(placement) === 'x';
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
let crossAxisMulti = 1;
if (alignment === 'end') {
crossAxisMulti = -1;
}
if (rtl && isVertical) {
crossAxisMulti *= -1;
}
const rawValue = typeof value === 'function' ? value({ ...rects,

@@ -720,8 +769,8 @@ placement

};
return getMainAxisFromPlacement(basePlacement) === 'x' ? {
x: crossAxis,
y: mainAxis * multiplier
return isVertical ? {
x: crossAxis * crossAxisMulti,
y: mainAxis * mainAxisMulti
} : {
x: mainAxis * multiplier,
y: crossAxis
x: mainAxis * mainAxisMulti,
y: crossAxis * crossAxisMulti
};

@@ -731,2 +780,3 @@ }

* Displaces the floating element from its reference element.
* @see https://floating-ui.com/docs/offset
*/

@@ -743,3 +793,3 @@

fn(middlewareArguments) {
async fn(middlewareArguments) {
const {

@@ -749,3 +799,5 @@ x,

placement,
rects
rects,
platform,
elements
} = middlewareArguments;

@@ -755,3 +807,4 @@ const diffCoords = convertValueToCoords({

rects,
value
value,
rtl: await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))
});

@@ -775,2 +828,3 @@ return {

* a clipping boundary.
* @see https://floating-ui.com/docs/shift
*/

@@ -814,3 +868,3 @@ const shift = function (options) {

const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const mainAxis = getMainAxisFromPlacement(getSide(placement));
const crossAxis = getCrossAxis(mainAxis);

@@ -911,3 +965,3 @@ let mainAxisCoord = coords[mainAxis];

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

@@ -936,2 +990,3 @@ 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);

* reference element.
* @see https://floating-ui.com/docs/size
*/

@@ -948,8 +1003,7 @@ const size = function (options) {

async fn(middlewareArguments) {
var _middlewareData$size;
const {
placement,
rects,
middlewareData
platform,
elements
} = middlewareArguments;

@@ -960,19 +1014,14 @@ const {

} = options;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const basePlacement = getBasePlacement(placement);
const isEnd = getAlignment(placement) === 'end';
const side = getSide(placement);
const alignment = getAlignment(placement);
let heightSide;
let widthSide;
if (basePlacement === 'top' || basePlacement === 'bottom') {
heightSide = basePlacement;
widthSide = isEnd ? 'left' : 'right';
if (side === 'top' || side === 'bottom') {
heightSide = side;
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))) ? 'start' : 'end') ? 'left' : 'right';
} else {
widthSide = basePlacement;
heightSide = isEnd ? 'top' : 'bottom';
widthSide = side;
heightSide = alignment === 'end' ? 'top' : 'bottom';
}

@@ -992,5 +1041,2 @@

return {
data: {
skip: true
},
reset: {

@@ -1008,2 +1054,3 @@ rects: true

* over multiple lines, such as hyperlinks or range selections.
* @see https://floating-ui.com/docs/inline
*/

@@ -1020,3 +1067,3 @@ const inline = function (options) {

async fn(middlewareArguments) {
var _middlewareData$inlin, _await$platform$getCl;
var _await$platform$getCl;

@@ -1028,4 +1075,3 @@ const {

platform,
strategy,
middlewareData
strategy
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a

@@ -1040,17 +1086,8 @@ // ClientRect's bounds, despite the event listener being triggered. A

} = options;
if ((_middlewareData$inlin = middlewareData.inline) != null && _middlewareData$inlin.skip) {
return {};
}
const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(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 : []);
}) : rects.reference);
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : []);
const paddingObject = getSideObjectFromPadding(padding);

@@ -1072,3 +1109,3 @@

const lastRect = clientRects[clientRects.length - 1];
const isTop = getBasePlacement(placement) === 'top';
const isTop = getSide(placement) === 'top';
const top = firstRect.top;

@@ -1092,6 +1129,6 @@ const bottom = lastRect.bottom;

const isLeftPlacement = getBasePlacement(placement) === 'left';
const isLeftSide = getSide(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 measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
const top = measureRects[0].top;

@@ -1119,5 +1156,2 @@ const bottom = measureRects[measureRects.length - 1].bottom;

return {
data: {
skip: true
},
reset: {

@@ -1124,0 +1158,0 @@ rects: await platform.getElementRects({

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

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

function getBasePlacement(placement) {
function getSide(placement) {
return placement.split('-')[0];

@@ -17,3 +17,3 @@ }

function getMainAxisFromPlacement(placement) {
return ['top', 'bottom'].includes(getBasePlacement(placement)) ? 'x' : 'y';
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
}

@@ -29,9 +29,15 @@

floating,
placement
placement,
rtl = false
} = _ref;
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
const commonAlign = reference[length] / 2 - floating[length] / 2;
const side = getSide(placement);
const isVertical = mainAxis === 'x';
let coords;
switch (getBasePlacement(placement)) {
switch (side) {
case 'top':

@@ -72,12 +78,9 @@ coords = {

const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
switch (getAlignment(placement)) {
case 'start':
coords[mainAxis] = coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
break;
case 'end':
coords[mainAxis] = coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
break;

@@ -104,2 +107,3 @@ }

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

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

} = computeCoordsFromPlacement({ ...rects,
placement
placement,
rtl
});
let statefulPlacement = placement;
let middlewareData = {};
const skippedMiddlewareNames = new Set();
let _debug_loop_count_ = 0;

@@ -150,2 +156,7 @@

} = middleware[i];
if (skippedMiddlewareNames.has(name)) {
continue;
}
const {

@@ -173,3 +184,5 @@ x: nextX,

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

@@ -195,4 +208,9 @@

} = computeCoordsFromPlacement({ ...rects,
placement: statefulPlacement
placement: statefulPlacement,
rtl
}));
if (reset.skip !== false) {
skippedMiddlewareNames.add(name);
}
}

@@ -248,4 +266,7 @@

* - 0 = lies flush with the boundary
* @see https://floating-ui.com/docs/detectOverflow
*/
async function detectOverflow(middlewareArguments, options) {
var _await$platform$isEle;
if (options === void 0) {

@@ -264,3 +285,3 @@ options = {};

const {
boundary = 'clippingParents',
boundary = 'clippingAncestors',
rootBoundary = 'viewport',

@@ -274,10 +295,8 @@ elementContext = 'floating',

const element = elements[altBoundary ? altContext : elementContext];
const clippingClientRect = await platform.getClippingClientRect({
element: (await platform.isElement(element)) ? element : element.contextElement || (await platform.getDocumentElement({
element: elements.floating
})),
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
boundary,
rootBoundary
});
const elementClientRect = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
}));
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: elementContext === 'floating' ? { ...rects.floating,

@@ -287,7 +306,5 @@ x,

} : rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
strategy
})); // positive = overflowing the clipping rect
}) : rects[elementContext]); // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect

@@ -313,2 +330,3 @@

* to the reference element.
* @see https://floating-ui.com/docs/arrow
*/

@@ -346,8 +364,5 @@ const arrow = options => ({

};
const basePlacement = getBasePlacement(placement);
const axis = getMainAxisFromPlacement(basePlacement);
const axis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(axis);
const arrowDimensions = await platform.getDimensions({
element
});
const arrowDimensions = await platform.getDimensions(element);
const minProp = axis === 'y' ? 'top' : 'left';

@@ -357,5 +372,3 @@ const maxProp = axis === 'y' ? 'bottom' : 'right';

const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = await platform.getOffsetParent({
element
});
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;

@@ -389,7 +402,11 @@ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center

function getAlignmentSides(placement, rects) {
const isStart = getAlignment(placement) === 'start';
function getAlignmentSides(placement, rects, rtl) {
if (rtl === void 0) {
rtl = false;
}
const alignment = getAlignment(placement);
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
let mainAlignmentSide = mainAxis === 'x' ? isStart ? 'right' : 'left' : isStart ? 'bottom' : 'top';
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';

@@ -414,7 +431,7 @@ if (rects.reference[length] > rects.floating[length]) {

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

@@ -431,2 +448,3 @@ if (alignment) {

* Automatically chooses the `placement` which has the most space available.
* @see https://floating-ui.com/docs/autoPlacement
*/

@@ -443,3 +461,3 @@ const autoPlacement = function (options) {

async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;

@@ -451,3 +469,5 @@ const {

middlewareData,
placement
placement,
platform,
elements
} = middlewareArguments;

@@ -460,10 +480,5 @@ const {

} = options;
if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {
return {};
}
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;
const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
const currentPlacement = placements[currentIndex];

@@ -473,3 +488,3 @@ const {

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

@@ -481,2 +496,3 @@ if (placement !== currentPlacement) {

reset: {
skip: false,
placement: placements[0]

@@ -487,4 +503,4 @@ }

const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...((_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : []), {
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {
placement: currentPlacement,

@@ -502,2 +518,3 @@ overflows: currentOverflows

reset: {
skip: false,
placement: nextPlacement

@@ -516,5 +533,2 @@ }

return {
data: {
skip: true
},
reset: {

@@ -537,2 +551,3 @@ placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement

* initially specified `placement` does not.
* @see https://floating-ui.com/docs/flip
*/

@@ -549,3 +564,3 @@ const flip = function (options) {

async fn(middlewareArguments) {
var _middlewareData$flip, _middlewareData$flip2;
var _middlewareData$flip;

@@ -556,9 +571,6 @@ const {

rects,
initialPlacement
initialPlacement,
platform,
elements
} = middlewareArguments;
if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {
return {};
}
const {

@@ -572,4 +584,4 @@ mainAxis: checkMainAxis = true,

} = options;
const basePlacement = getBasePlacement(placement);
const isBasePlacement = basePlacement === initialPlacement;
const side = getSide(placement);
const isBasePlacement = side === initialPlacement;
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));

@@ -579,6 +591,6 @@ const placements = [initialPlacement, ...fallbackPlacements];

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

@@ -590,3 +602,3 @@

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

@@ -601,5 +613,5 @@ }

if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip3;
var _middlewareData$flip$, _middlewareData$flip2;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];

@@ -615,2 +627,3 @@

reset: {
skip: false,
placement: nextPlacement

@@ -643,5 +656,2 @@ }

return {
data: {
skip: true
},
reset: {

@@ -669,35 +679,61 @@ placement: resetPlacement

function isAnySideFullyClipped(overflow) {
return basePlacements.some(side => overflow[side] >= 0);
return sides.some(side => overflow[side] >= 0);
}
/**
* Provides data to hide the floating element in applicable situations, such as
* when it is not in the same clipping context as the reference element.
* @see https://floating-ui.com/docs/hide
*/
const hide = function (_temp) {
let {
strategy = 'referenceHidden',
...detectOverflowOptions
} = _temp === void 0 ? {} : _temp;
return {
name: 'hide',
async fn(middlewareArguments) {
const {
rects
} = middlewareArguments;
const hide = () => ({
name: 'hide',
switch (strategy) {
case 'referenceHidden':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
elementContext: 'reference'
});
const offsets = getSideOffsets(overflow, rects.reference);
return {
data: {
referenceHiddenOffsets: offsets,
referenceHidden: isAnySideFullyClipped(offsets)
}
};
}
async fn(modifierArguments) {
const referenceOverflow = await detectOverflow(modifierArguments, {
elementContext: 'reference'
});
const floatingAltOverflow = await detectOverflow(modifierArguments, {
altBoundary: true
});
const referenceHiddenOffsets = getSideOffsets(referenceOverflow, modifierArguments.rects.reference);
const escapedOffsets = getSideOffsets(floatingAltOverflow, modifierArguments.rects.floating);
const referenceHidden = isAnySideFullyClipped(referenceHiddenOffsets);
const escaped = isAnySideFullyClipped(escapedOffsets);
return {
data: {
referenceHidden,
referenceHiddenOffsets,
escaped,
escapedOffsets
case 'escaped':
{
const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
altBoundary: true
});
const offsets = getSideOffsets(overflow, rects.floating);
return {
data: {
escapedOffsets: offsets,
escaped: isAnySideFullyClipped(offsets)
}
};
}
default:
{
return {};
}
}
};
}
}
});
};
};

@@ -708,6 +744,19 @@ function convertValueToCoords(_ref) {

rects,
value
value,
rtl = false
} = _ref;
const basePlacement = getBasePlacement(placement);
const multiplier = ['left', 'top'].includes(basePlacement) ? -1 : 1;
const side = getSide(placement);
const alignment = getAlignment(placement);
const isVertical = getMainAxisFromPlacement(placement) === 'x';
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
let crossAxisMulti = 1;
if (alignment === 'end') {
crossAxisMulti = -1;
}
if (rtl && isVertical) {
crossAxisMulti *= -1;
}
const rawValue = typeof value === 'function' ? value({ ...rects,

@@ -727,8 +776,8 @@ placement

};
return getMainAxisFromPlacement(basePlacement) === 'x' ? {
x: crossAxis,
y: mainAxis * multiplier
return isVertical ? {
x: crossAxis * crossAxisMulti,
y: mainAxis * mainAxisMulti
} : {
x: mainAxis * multiplier,
y: crossAxis
x: mainAxis * mainAxisMulti,
y: crossAxis * crossAxisMulti
};

@@ -738,2 +787,3 @@ }

* Displaces the floating element from its reference element.
* @see https://floating-ui.com/docs/offset
*/

@@ -750,3 +800,3 @@

fn(middlewareArguments) {
async fn(middlewareArguments) {
const {

@@ -756,3 +806,5 @@ x,

placement,
rects
rects,
platform,
elements
} = middlewareArguments;

@@ -762,3 +814,4 @@ const diffCoords = convertValueToCoords({

rects,
value
value,
rtl: await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))
});

@@ -782,2 +835,3 @@ return {

* a clipping boundary.
* @see https://floating-ui.com/docs/shift
*/

@@ -821,3 +875,3 @@ const shift = function (options) {

const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const mainAxis = getMainAxisFromPlacement(getSide(placement));
const crossAxis = getCrossAxis(mainAxis);

@@ -918,3 +972,3 @@ let mainAxisCoord = coords[mainAxis];

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

@@ -943,2 +997,3 @@ 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);

* reference element.
* @see https://floating-ui.com/docs/size
*/

@@ -955,8 +1010,7 @@ const size = function (options) {

async fn(middlewareArguments) {
var _middlewareData$size;
const {
placement,
rects,
middlewareData
platform,
elements
} = middlewareArguments;

@@ -967,19 +1021,14 @@ const {

} = options;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const basePlacement = getBasePlacement(placement);
const isEnd = getAlignment(placement) === 'end';
const side = getSide(placement);
const alignment = getAlignment(placement);
let heightSide;
let widthSide;
if (basePlacement === 'top' || basePlacement === 'bottom') {
heightSide = basePlacement;
widthSide = isEnd ? 'left' : 'right';
if (side === 'top' || side === 'bottom') {
heightSide = side;
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.reference))) ? 'start' : 'end') ? 'left' : 'right';
} else {
widthSide = basePlacement;
heightSide = isEnd ? 'top' : 'bottom';
widthSide = side;
heightSide = alignment === 'end' ? 'top' : 'bottom';
}

@@ -999,5 +1048,2 @@

return {
data: {
skip: true
},
reset: {

@@ -1015,2 +1061,3 @@ rects: true

* over multiple lines, such as hyperlinks or range selections.
* @see https://floating-ui.com/docs/inline
*/

@@ -1027,3 +1074,3 @@ const inline = function (options) {

async fn(middlewareArguments) {
var _middlewareData$inlin, _await$platform$getCl;
var _await$platform$getCl;

@@ -1035,4 +1082,3 @@ const {

platform,
strategy,
middlewareData
strategy
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a

@@ -1047,17 +1093,8 @@ // ClientRect's bounds, despite the event listener being triggered. A

} = options;
if ((_middlewareData$inlin = middlewareData.inline) != null && _middlewareData$inlin.skip) {
return {};
}
const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: rects.reference,
offsetParent: await platform.getOffsetParent({
element: elements.floating
}),
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(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 : []);
}) : rects.reference);
const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : []);
const paddingObject = getSideObjectFromPadding(padding);

@@ -1079,3 +1116,3 @@

const lastRect = clientRects[clientRects.length - 1];
const isTop = getBasePlacement(placement) === 'top';
const isTop = getSide(placement) === 'top';
const top = firstRect.top;

@@ -1099,6 +1136,6 @@ const bottom = lastRect.bottom;

const isLeftPlacement = getBasePlacement(placement) === 'left';
const isLeftSide = getSide(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 measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
const top = measureRects[0].top;

@@ -1126,5 +1163,2 @@ const bottom = measureRects[measureRects.length - 1].bottom;

return {
data: {
skip: true
},
reset: {

@@ -1131,0 +1165,0 @@ rects: await platform.getElementRects({

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

@@ -15,3 +15,3 @@ "baseVersion": [

},
"main": "dist/floating-ui.core.cjs",
"main": "dist/floating-ui.core.js",
"module": "dist/floating-ui.core.esm.js",

@@ -18,0 +18,0 @@ "unpkg": "dist/floating-ui.core.min.js",

import type { Placement, ElementRects, Coords } from './types';
export declare function computeCoordsFromPlacement({ reference, floating, placement, }: ElementRects & {
export declare function computeCoordsFromPlacement({ reference, floating, placement, rtl, }: ElementRects & {
placement: Placement;
rtl?: boolean;
}): Coords;
import type { SideObject, Padding, Boundary, RootBoundary, ElementContext, MiddlewareArguments } from './types';
export declare type Options = {
export interface Options {
/**
* The clipping element(s) in which overflow will be checked.
* @default 'clippingAncestors'
*/

@@ -9,2 +10,3 @@ boundary: Boundary;

* The root clipping element in which overflow will be checked.
* @default 'viewport'
*/

@@ -14,2 +16,3 @@ rootBoundary: RootBoundary;

* The element in which overflow is being checked relative to a boundary.
* @default 'floating'
*/

@@ -19,3 +22,4 @@ elementContext: ElementContext;

* Whether to check for overflow using the alternate element's boundary
* (`clippingParents` boundary only).
* (`clippingAncestors` boundary only).
* @default false
*/

@@ -25,5 +29,6 @@ altBoundary: boolean;

* Virtual padding for the resolved overflow offsets.
* @default 0
*/
padding: Padding;
};
}
/**

@@ -35,3 +40,4 @@ * Resolves with an object of overflow side offsets that determine how much the

* - 0 = lies flush with the boundary
* @see https://floating-ui.com/docs/detectOverflow
*/
export declare function detectOverflow(middlewareArguments: MiddlewareArguments, options?: Partial<Options>): Promise<SideObject>;

@@ -1,4 +0,3 @@

import { Placement } from '..';
import { BasePlacement } from './types';
export declare const basePlacements: BasePlacement[];
import type { Side, Placement } from './types';
export declare const sides: Side[];
export declare const allPlacements: Placement[];
import type { Middleware, Padding } from '../types';
export declare type Options = {
export interface Options {
/**
* The arrow element to be positioned.
* @default undefined
*/

@@ -10,9 +11,11 @@ element: any;

* Useful when the floating element has rounded corners.
* @default 0
*/
padding?: Padding;
};
}
/**
* Positions an inner element of the floating element such that it is centered
* to the reference element.
* @see https://floating-ui.com/docs/arrow
*/
export declare const arrow: (options: Options) => Middleware;
import type { Middleware, Placement, Alignment } from '../types';
import { Options as DetectOverflowOptions } from '../detectOverflow';
export declare function getPlacementList(alignment: Alignment | null, autoAlignment: boolean, allowedPlacements: Array<Placement>): Placement[];
export declare type Options = {
export interface Options {
/**
* Choose placements with a particular alignment.
* @default null
*/

@@ -12,2 +13,3 @@ alignment: Alignment | null;

* `alignment` option set.
* @default allPlacements (variable)
*/

@@ -18,8 +20,10 @@ allowedPlacements: Array<Placement>;

* better.
* @default true
*/
autoAlignment: boolean;
};
}
/**
* Automatically chooses the `placement` which has the most space available.
* @see https://floating-ui.com/docs/autoPlacement
*/
export declare const autoPlacement: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
import type { Placement, Middleware } from '../types';
import { Options as DetectOverflowOptions } from '../detectOverflow';
export declare type Options = {
export interface Options {
/**
* The axis that runs along the side of the floating element.
* @default true
*/

@@ -10,2 +11,3 @@ mainAxis: boolean;

* The axis that runs along the alignment of the floating element.
* @default true
*/

@@ -15,2 +17,3 @@ crossAxis: boolean;

* Placements to try if the preferred `placement` does not fit.
* @default [oppositePlacement] (computed)
*/

@@ -20,2 +23,3 @@ fallbackPlacements: Array<Placement>;

* What strategy to use when no placements fit.
* @default 'bestFit'
*/

@@ -26,9 +30,11 @@ fallbackStrategy: 'bestFit' | 'initialPlacement';

* better.
* @default true
*/
flipAlignment: boolean;
};
}
/**
* Changes the placement of the floating element to one that will fit if the
* initially specified `placement` does not.
* @see https://floating-ui.com/docs/flip
*/
export declare const flip: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
import type { Middleware } from '../types';
import { Options as DetectOverflowOptions } from '../detectOverflow';
export interface Options {
strategy: 'referenceHidden' | 'escaped';
}
/**
* Provides data to hide the floating element in applicable situations, such as
* when it is not in the same clipping context as the reference element.
* @see https://floating-ui.com/docs/hide
*/
export declare const hide: () => Middleware;
export declare const hide: ({ strategy, ...detectOverflowOptions }?: Partial<Options & DetectOverflowOptions>) => Middleware;

@@ -1,12 +0,24 @@

import type { Coords, Middleware, Padding } from '../types';
export declare type Options = Coords & {
import type { Middleware, Padding } from '../types';
export interface Options {
/**
* Viewport-relative `x` coordinate to choose a `ClientRect`.
* @default undefined
*/
x: number;
/**
* Viewport-relative `y` coordinate to choose a `ClientRect`.
* @default undefined
*/
y: number;
/**
* @experimental
* @default 2
*/
padding: Padding;
};
}
/**
* Provides improved positioning for inline reference elements that can span
* over multiple lines, such as hyperlinks or range selections.
* @see https://floating-ui.com/docs/inline
*/
export declare const inline: (options?: Partial<Options>) => Middleware;

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

export declare type Options = OffsetValue | OffsetFunction;
export declare function convertValueToCoords({ placement, rects, value, }: {
export declare function convertValueToCoords({ placement, rects, value, rtl, }: {
placement: Placement;

@@ -26,7 +26,9 @@ rects: {

value: Options;
rtl?: boolean;
}): Coords;
/**
* Displaces the floating element from its reference element.
* @see https://floating-ui.com/docs/offset
*/
export declare const offset: (value?: Options) => Middleware;
export {};
import type { Middleware, Rect, Placement, MiddlewareArguments, Coords } from '../types';
import { Options as DetectOverflowOptions } from '../detectOverflow';
export declare type Options = {
export interface Options {
/**
* The axis that runs along the alignment of the floating element.
* @default true
*/

@@ -10,2 +11,3 @@ mainAxis: boolean;

* The axis that runs along the side of the floating element.
* @default false
*/

@@ -21,6 +23,7 @@ crossAxis: boolean;

};
};
}
/**
* Shifts the floating element in order to keep it in view when it will overflow
* a clipping boundary.
* @see https://floating-ui.com/docs/shift
*/

@@ -27,0 +30,0 @@ export declare const shift: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;

import type { Dimensions, ElementRects, Middleware } from '../types';
import { Options as DetectOverflowOptions } from '../detectOverflow';
export declare type Options = {
export interface Options {
/**
* Function that is called to perform style mutations to the floating element
* to change its size.
* @default undefined
*/
apply(args: Dimensions & ElementRects): void;
};
}
/**

@@ -14,3 +15,4 @@ * Provides data to change the size of the floating element. For instance,

* reference element.
* @see https://floating-ui.com/docs/size
*/
export declare const size: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
export declare type Alignment = 'start' | 'end';
export declare type BasePlacement = 'top' | 'right' | 'bottom' | 'left';
export declare type AlignedPlacement = `${BasePlacement}-${Alignment}`;
export declare type Placement = BasePlacement | AlignedPlacement;
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';

@@ -9,3 +9,7 @@ export declare type Axis = 'x' | 'y';

declare type Promisable<T> = T | Promise<T>;
export declare type Platform = {
/**
* Platform interface methods to work with the current platform.
* @see https://floating-ui.com/docs/platform
*/
export interface Platform {
getElementRects: (args: {

@@ -16,3 +20,9 @@ reference: ReferenceElement;

}) => Promisable<ElementRects>;
convertOffsetParentRelativeRectToViewportRelativeRect: (args: {
getClippingRect: (args: {
element: any;
boundary: Boundary;
rootBoundary: RootBoundary;
}) => Promisable<Rect>;
getDimensions: (element: any) => Promisable<Dimensions>;
convertOffsetParentRelativeRectToViewportRelativeRect?: (args: {
rect: Rect;

@@ -22,21 +32,8 @@ offsetParent: any;

}) => Promisable<Rect>;
getOffsetParent: (args: {
element: any;
}) => Promisable<any>;
isElement: (value: unknown) => Promisable<boolean>;
getDocumentElement: (args: {
element: any;
}) => Promisable<any>;
getClippingClientRect: (args: {
element: any;
boundary: Boundary;
rootBoundary: RootBoundary;
}) => Promisable<ClientRectObject>;
getDimensions: (args: {
element: any;
}) => Promisable<Dimensions>;
getClientRects?: (args: {
element: any;
}) => Promisable<Array<ClientRectObject>>;
};
getOffsetParent?: (element: any) => Promisable<any>;
isElement?: (value: any) => Promisable<boolean>;
getDocumentElement?: (element: any) => Promisable<any>;
getClientRects?: (element: any) => Promisable<Array<ClientRectObject>>;
isRTL?: (element: any) => Promisable<boolean>;
}
export declare type Coords = {

@@ -46,5 +43,6 @@ [key in Axis]: number;

export declare type SideObject = {
[key in BasePlacement]: number;
[key in Side]: number;
};
export declare type MiddlewareData = {
export interface MiddlewareData {
[key: string]: any;
arrow?: Partial<Coords> & {

@@ -55,3 +53,2 @@ centerOffset: number;

index?: number;
skip?: boolean;
overflows: Array<{

@@ -64,3 +61,2 @@ placement: Placement;

index?: number;
skip?: boolean;
overflows: Array<{

@@ -72,17 +68,11 @@ placement: Placement;

hide?: {
referenceHidden: boolean;
escaped: boolean;
referenceHiddenOffsets: SideObject;
escapedOffsets: SideObject;
referenceHidden?: boolean;
escaped?: boolean;
referenceHiddenOffsets?: SideObject;
escapedOffsets?: SideObject;
};
inline?: {
skip?: boolean;
};
size?: {
skip?: boolean;
};
offset?: Coords;
[key: string]: any;
};
export declare type ComputePositionConfig = {
shift?: Coords;
}
export interface ComputePositionConfig {
platform: Platform;

@@ -92,18 +82,19 @@ placement?: Placement;

middleware?: Array<Middleware>;
};
export declare type ComputePositionReturn = Coords & {
}
export interface ComputePositionReturn extends Coords {
placement: Placement;
strategy: Strategy;
middlewareData: MiddlewareData;
};
}
export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
export declare type MiddlewareReturn = Partial<Coords & {
data: {
export interface MiddlewareReturn extends Partial<Coords> {
data?: {
[key: string]: any;
};
reset: true | {
reset?: true | {
placement?: Placement;
rects?: true | ElementRects;
skip?: false;
};
}>;
}
export declare type Middleware = {

@@ -118,6 +109,10 @@ name: string;

export declare type Rect = Coords & Dimensions;
export declare type ElementRects = {
export interface ElementRects {
reference: Rect;
floating: Rect;
};
}
/**
* Custom positioning reference element.
* @see https://floating-ui.com/docs/virtual-elements
*/
export declare type VirtualElement = {

@@ -129,7 +124,7 @@ getBoundingClientRect(): ClientRectObject;

export declare type FloatingElement = any;
export declare type Elements = {
export interface Elements {
reference: ReferenceElement;
floating: FloatingElement;
};
export declare type MiddlewareArguments = Coords & {
}
export interface MiddlewareArguments extends Coords {
initialPlacement: Placement;

@@ -142,3 +137,3 @@ placement: Placement;

platform: Platform;
};
}
export declare type ClientRectObject = Rect & SideObject;

@@ -145,0 +140,0 @@ export declare type Padding = number | SideObject;

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

import type { ElementRects, Placement, BasePlacement } from '../types';
export declare function getAlignmentSides(placement: Placement, rects: ElementRects): {
main: BasePlacement;
cross: BasePlacement;
import type { ElementRects, Placement, Side } from '../types';
export declare function getAlignmentSides(placement: Placement, rects: ElementRects, rtl?: boolean): {
main: Side;
cross: Side;
};

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

import { Axis } from '../types';
import type { Axis } from '../types';
export declare function getCrossAxis(axis: Axis): Axis;

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

import { Axis, Length } from '../types';
import type { Axis, Length } from '../types';
export declare function getLengthFromAxis(axis: Axis): Length;

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

import { Axis, Placement } from '../types';
import type { Axis, Placement } from '../types';
export declare function getMainAxisFromPlacement(placement: Placement): Axis;

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