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

@floating-ui/core

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/core - npm Package Compare versions

Comparing version

to
1.3.0

src/utils/evaluate.d.ts

68

dist/floating-ui.core.esm.js

@@ -164,2 +164,6 @@ function getAlignment(placement) {

function evaluate(value, param) {
return typeof value === 'function' ? value(param) : value;
}
function expandPaddingObject(padding) {

@@ -221,3 +225,3 @@ return {

padding = 0
} = options;
} = evaluate(options, state);
const paddingObject = getSideObjectFromPadding(padding);

@@ -274,8 +278,3 @@ const altContext = elementContext === 'floating' ? 'reference' : 'floating';

async fn(state) {
// Since `element` is required, we don't Partial<> the type.
const {
element,
padding = 0
} = options || {};
const {
x,

@@ -288,2 +287,7 @@ y,

} = state;
// Since `element` is required, we don't Partial<> the type.
const {
element,
padding = 0
} = evaluate(options, state) || {};
if (element == null) {

@@ -315,8 +319,14 @@ return {};

// If the padding is large enough that it causes the arrow to no longer be
// centered, modify the padding so that it is centered.
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
// Make sure the arrow doesn't overflow the floating element if the center
// point is outside the floating element's bounds.
const min = paddingObject[minProp];
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const min$1 = minPadding;
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = within(min, center, max);
const offset = within(min$1, center, max);

@@ -327,4 +337,4 @@ // If the reference is small enough that the arrow's padding causes it to

// be worked around by calling it again after the `arrow()` if desired.
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min$1 ? min$1 - center : max - center : 0;
return {

@@ -415,3 +425,3 @@ [axis]: coords[axis] - alignmentOffset,

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;

@@ -550,3 +560,3 @@ const overflow = await detectOverflow(state, detectOverflowOptions);

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const side = getSide(placement);

@@ -655,8 +665,8 @@ const isBasePlacement = getSide(initialPlacement) === initialPlacement;

const {
rects
} = state;
const {
strategy = 'referenceHidden',
...detectOverflowOptions
} = options;
const {
rects
} = state;
} = evaluate(options, state);
switch (strategy) {

@@ -754,3 +764,3 @@ case 'referenceHidden':

y
} = options;
} = evaluate(options, state);
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);

@@ -832,3 +842,3 @@ const clientRects = getRectsByLine(nativeClientRects);

async function convertValueToCoords(state, value) {
async function convertValueToCoords(state, options) {
const {

@@ -845,3 +855,3 @@ placement,

const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = typeof value === 'function' ? value(state) : value;
const rawValue = evaluate(options, state);

@@ -882,9 +892,9 @@ // eslint-disable-next-line prefer-const

*/
const offset = function (value) {
if (value === void 0) {
value = 0;
const offset = function (options) {
if (options === void 0) {
options = 0;
}
return {
name: 'offset',
options: value,
options,
async fn(state) {

@@ -895,3 +905,3 @@ const {

} = state;
const diffCoords = await convertValueToCoords(state, value);
const diffCoords = await convertValueToCoords(state, options);
return {

@@ -944,3 +954,3 @@ x: x + diffCoords.x,

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const coords = {

@@ -1005,3 +1015,3 @@ x,

crossAxis: checkCrossAxis = true
} = options;
} = evaluate(options, state);
const coords = {

@@ -1015,3 +1025,3 @@ x,

let crossAxisCoord = coords[crossAxis];
const rawOffset = typeof offset === 'function' ? offset(state) : offset;
const rawOffset = evaluate(offset, state);
const computedOffset = typeof rawOffset === 'number' ? {

@@ -1078,3 +1088,3 @@ mainAxis: rawOffset,

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const overflow = await detectOverflow(state, detectOverflowOptions);

@@ -1081,0 +1091,0 @@ const side = getSide(placement);

@@ -170,2 +170,6 @@ (function (global, factory) {

function evaluate(value, param) {
return typeof value === 'function' ? value(param) : value;
}
function expandPaddingObject(padding) {

@@ -227,3 +231,3 @@ return {

padding = 0
} = options;
} = evaluate(options, state);
const paddingObject = getSideObjectFromPadding(padding);

@@ -280,8 +284,3 @@ const altContext = elementContext === 'floating' ? 'reference' : 'floating';

async fn(state) {
// Since `element` is required, we don't Partial<> the type.
const {
element,
padding = 0
} = options || {};
const {
x,

@@ -294,2 +293,7 @@ y,

} = state;
// Since `element` is required, we don't Partial<> the type.
const {
element,
padding = 0
} = evaluate(options, state) || {};
if (element == null) {

@@ -321,8 +325,14 @@ return {};

// If the padding is large enough that it causes the arrow to no longer be
// centered, modify the padding so that it is centered.
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
// Make sure the arrow doesn't overflow the floating element if the center
// point is outside the floating element's bounds.
const min = paddingObject[minProp];
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const min$1 = minPadding;
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = within(min, center, max);
const offset = within(min$1, center, max);

@@ -333,4 +343,4 @@ // If the reference is small enough that the arrow's padding causes it to

// be worked around by calling it again after the `arrow()` if desired.
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < min$1 ? min$1 - center : max - center : 0;
return {

@@ -421,3 +431,3 @@ [axis]: coords[axis] - alignmentOffset,

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;

@@ -556,3 +566,3 @@ const overflow = await detectOverflow(state, detectOverflowOptions);

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const side = getSide(placement);

@@ -661,8 +671,8 @@ const isBasePlacement = getSide(initialPlacement) === initialPlacement;

const {
rects
} = state;
const {
strategy = 'referenceHidden',
...detectOverflowOptions
} = options;
const {
rects
} = state;
} = evaluate(options, state);
switch (strategy) {

@@ -760,3 +770,3 @@ case 'referenceHidden':

y
} = options;
} = evaluate(options, state);
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);

@@ -838,3 +848,3 @@ const clientRects = getRectsByLine(nativeClientRects);

async function convertValueToCoords(state, value) {
async function convertValueToCoords(state, options) {
const {

@@ -851,3 +861,3 @@ placement,

const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = typeof value === 'function' ? value(state) : value;
const rawValue = evaluate(options, state);

@@ -888,9 +898,9 @@ // eslint-disable-next-line prefer-const

*/
const offset = function (value) {
if (value === void 0) {
value = 0;
const offset = function (options) {
if (options === void 0) {
options = 0;
}
return {
name: 'offset',
options: value,
options,
async fn(state) {

@@ -901,3 +911,3 @@ const {

} = state;
const diffCoords = await convertValueToCoords(state, value);
const diffCoords = await convertValueToCoords(state, options);
return {

@@ -950,3 +960,3 @@ x: x + diffCoords.x,

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const coords = {

@@ -1011,3 +1021,3 @@ x,

crossAxis: checkCrossAxis = true
} = options;
} = evaluate(options, state);
const coords = {

@@ -1021,3 +1031,3 @@ x,

let crossAxisCoord = coords[crossAxis];
const rawOffset = typeof offset === 'function' ? offset(state) : offset;
const rawOffset = evaluate(offset, state);
const computedOffset = typeof rawOffset === 'number' ? {

@@ -1084,3 +1094,3 @@ mainAxis: rawOffset,

...detectOverflowOptions
} = options;
} = evaluate(options, state);
const overflow = await detectOverflow(state, detectOverflowOptions);

@@ -1087,0 +1097,0 @@ const side = getSide(placement);

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

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

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

import type { Boundary, ElementContext, MiddlewareState, Padding, RootBoundary, SideObject } from './types';
export interface Options {
import type { Boundary, Derivable, ElementContext, MiddlewareState, Padding, RootBoundary, SideObject } from './types';
export type Options = Partial<{
/**

@@ -29,3 +29,3 @@ * The clipping element(s) or area in which overflow will be checked.

padding: Padding;
}
}>;
/**

@@ -39,2 +39,2 @@ * Resolves with an object of overflow side offsets that determine how much the

*/
export declare function detectOverflow(state: MiddlewareState, options?: Partial<Options>): Promise<SideObject>;
export declare function detectOverflow(state: MiddlewareState, options?: Options | Derivable<Options>): Promise<SideObject>;

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

import type { Middleware, Padding } from '../types';
export interface Options {
import type { Derivable, Middleware, Padding } from '../types';
export interface ArrowOptions {
/**

@@ -20,2 +20,2 @@ * The arrow element to be positioned.

*/
export declare const arrow: (options: Options) => Middleware;
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
import { Options as DetectOverflowOptions } from '../detectOverflow';
import type { Alignment, Middleware, Placement } from '../types';
import type { Alignment, Derivable, Middleware, Placement } from '../types';
export declare function getPlacementList(alignment: Alignment | null, autoAlignment: boolean, allowedPlacements: Array<Placement>): Placement[];
export interface Options {
export type AutoPlacementOptions = Partial<DetectOverflowOptions & {
/**

@@ -28,3 +28,3 @@ * The axis that runs along the alignment of the floating element. Determines

allowedPlacements: Array<Placement>;
}
}>;
/**

@@ -36,2 +36,2 @@ * Optimizes the visibility of the floating element by choosing the placement

*/
export declare const autoPlacement: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;

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

import { Options as DetectOverflowOptions } from '../detectOverflow';
import type { Middleware, Placement } from '../types';
export interface Options {
import type { Derivable, DetectOverflowOptions, Middleware, Placement } from '../types';
export type FlipOptions = Partial<DetectOverflowOptions & {
/**

@@ -38,3 +37,3 @@ * The axis that runs along the side of the floating element. Determines

flipAlignment: boolean;
}
}>;
/**

@@ -46,2 +45,2 @@ * Optimizes the visibility of the floating element by flipping the `placement`

*/
export declare const flip: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
import { Options as DetectOverflowOptions } from '../detectOverflow';
import type { Middleware } from '../types';
export interface Options {
import type { Derivable, Middleware } from '../types';
export type HideOptions = Partial<DetectOverflowOptions & {
/**

@@ -8,3 +8,3 @@ * The strategy used to determine when to hide the floating element.

strategy: 'referenceHidden' | 'escaped';
}
}>;
/**

@@ -15,2 +15,2 @@ * Provides data to hide the floating element in applicable situations, such as

*/
export declare const hide: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;

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

import type { ClientRectObject, Middleware, Padding } from '../types';
import type { ClientRectObject, Derivable, Middleware, Padding } from '../types';
export declare function getRectsByLine(rects: Array<ClientRectObject>): ClientRectObject[];
export interface Options {
export type InlineOptions = Partial<{
/**

@@ -19,3 +19,3 @@ * Viewport-relative `x` coordinate to choose a `ClientRect`.

padding: Padding;
}
}>;
/**

@@ -26,2 +26,2 @@ * Provides improved positioning for inline reference elements that can span

*/
export declare const inline: (options?: Partial<Options>) => Middleware;
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;

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

import type { Coords, Middleware, MiddlewareState } from '../types';
type OffsetValue = number | {
import type { Coords, Derivable, Middleware, MiddlewareState } from '../types';
type OffsetValue = number | Partial<{
/**

@@ -9,3 +9,3 @@ * The axis that runs along the side of the floating element. Represents

*/
mainAxis?: number;
mainAxis: number;
/**

@@ -16,3 +16,3 @@ * The axis that runs along the alignment of the floating element.

*/
crossAxis?: number;
crossAxis: number;
/**

@@ -28,7 +28,6 @@ * The same axis as `crossAxis` but applies only to aligned placements

*/
alignmentAxis?: number | null;
};
type OffsetFunction = (state: MiddlewareState) => OffsetValue;
export type Options = OffsetValue | OffsetFunction;
export declare function convertValueToCoords(state: MiddlewareState, value: Options): Promise<Coords>;
alignmentAxis: number | null;
}>;
export type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
export declare function convertValueToCoords(state: MiddlewareState, options: OffsetOptions): Promise<Coords>;
/**

@@ -41,3 +40,3 @@ * Modifies the placement by translating the floating element along the

*/
export declare const offset: (value?: Options) => Middleware;
export declare const offset: (options?: OffsetOptions) => Middleware;
export {};
import { Options as DetectOverflowOptions } from '../detectOverflow';
import type { Coords, Middleware, MiddlewareState } from '../types';
export interface Options {
import type { Coords, Derivable, Middleware, MiddlewareState } from '../types';
export type ShiftOptions = Partial<DetectOverflowOptions & {
/**

@@ -24,3 +24,3 @@ * The axis that runs along the alignment of the floating element. Determines

};
}
}>;
/**

@@ -31,4 +31,4 @@ * Optimizes the visibility of the floating element by shifting it in order to

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

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

*/
mainAxis?: number;
mainAxis: number;
/**

@@ -44,17 +44,6 @@ * Offset the limiting of the axis that runs along the side of the

*/
crossAxis?: number;
}) | number | {
crossAxis: number;
}>;
export type LimitShiftOptions = Partial<{
/**
* Offset the limiting of the axis that runs along the alignment of the
* floating element.
*/
mainAxis?: number;
/**
* Offset the limiting of the axis that runs along the side of the
* floating element.
*/
crossAxis?: number;
};
export type LimitShiftOptions = {
/**
* Offset when limiting starts. `0` will limit when the opposite edges of the

@@ -65,3 +54,3 @@ * reference and floating elements are aligned.

*/
offset: LimitShiftOffset;
offset: LimitShiftOffset | Derivable<LimitShiftOffset>;
/**

@@ -76,10 +65,10 @@ * Whether to limit the axis that runs along the alignment of the floating

crossAxis: boolean;
};
}>;
/**
* Built-in `limiter` that will stop `shift()` at a certain point.
*/
export declare const limitShift: (options?: Partial<LimitShiftOptions>) => {
options: Partial<LimitShiftOffset>;
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
options: any;
fn: (state: MiddlewareState) => Coords;
};
export {};
import { Options as DetectOverflowOptions } from '../detectOverflow';
import type { Middleware, MiddlewareState } from '../types';
export interface Options {
import type { Derivable, Middleware, MiddlewareState } from '../types';
export type SizeOptions = Partial<DetectOverflowOptions & {
/**

@@ -13,3 +13,3 @@ * Function that is called to perform style mutations to the floating element

}): void | Promise<void>;
}
}>;
/**

@@ -21,2 +21,2 @@ * Provides data that allows you to change the size of the floating element —

*/
export declare const size: (options?: Partial<Options & DetectOverflowOptions>) => Middleware;
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;

@@ -10,2 +10,6 @@ export type Alignment = 'start' | 'end';

/**
* Function option to derive middleware options from state.
*/
export type Derivable<T> = (state: MiddlewareState) => T;
/**
* Platform interface methods to work with the current platform.

@@ -77,10 +81,32 @@ * @see https://floating-ui.com/docs/platform

export interface ComputePositionConfig {
/**
* Object to interface with the current platform.
*/
platform: Platform;
/**
* Where to place the floating element relative to the reference element.
*/
placement?: Placement;
/**
* The strategy to use when positioning the floating element.
*/
strategy?: Strategy;
/**
* Array of middleware objects to modify the positioning or provide data for
* rendering.
*/
middleware?: Array<Middleware | null | undefined | false>;
}
export interface ComputePositionReturn extends Coords {
/**
* The final chosen placement of the floating element.
*/
placement: Placement;
/**
* The strategy used to position the floating element.
*/
strategy: Strategy;
/**
* Object containing data returned from all middleware, keyed by their name.
*/
middlewareData: MiddlewareData;

@@ -145,10 +171,10 @@ }

export { detectOverflow, Options as DetectOverflowOptions, } from './detectOverflow';
export { arrow, Options as ArrowOptions } from './middleware/arrow';
export { autoPlacement, Options as AutoPlacementOptions, } from './middleware/autoPlacement';
export { flip, Options as FlipOptions } from './middleware/flip';
export { hide, Options as HideOptions } from './middleware/hide';
export { inline, Options as InlineOptions } from './middleware/inline';
export { offset, Options as OffsetOptions } from './middleware/offset';
export { limitShift, LimitShiftOptions, shift, Options as ShiftOptions, } from './middleware/shift';
export { size, Options as SizeOptions } from './middleware/size';
export { arrow, ArrowOptions } from './middleware/arrow';
export { autoPlacement, AutoPlacementOptions } from './middleware/autoPlacement';
export { flip, FlipOptions } from './middleware/flip';
export { hide, HideOptions } from './middleware/hide';
export { inline, InlineOptions } from './middleware/inline';
export { offset, OffsetOptions } from './middleware/offset';
export { limitShift, LimitShiftOptions, shift, ShiftOptions, } from './middleware/shift';
export { size, SizeOptions } from './middleware/size';
export { rectToClientRect } from './utils/rectToClientRect';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet