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.3.0 to 0.3.1

4

dist/floating-ui.core.esm.js

@@ -824,4 +824,4 @@ function getBasePlacement(placement) {

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

@@ -828,0 +828,0 @@ if (crossAxisCoord < limitMin) {

@@ -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]-(null!=(w=null==(b=s.offset)?void 0:b[p])?w:0)+(n?0:x.crossAxis),o=l.reference[g]+l.reference[e]+(null!=(v=null==(A=s.offset)?void 0:A[p])?v:0)-(n?x.crossAxis:0);h<r?h=r:h>o&&(h=o)}return{[p]:d,[g]:h}}}},E=function(n){return void 0===n&&(n={}),{name:"size",options:n,async fn(r){var o;const{placement:i,rects:a,middlewareData:l}=r,{apply:c,...m}=n;if(null!=(o=l.size)&&o.skip)return{};const u=await s(r,m),p=t(i),g="end"===e(i);let d,h;"top"===p||"bottom"===p?(d=p,h=g?"left":"right"):(h=p,d=g?"top":"bottom");const y=f(u.left,0),x=f(u.right,0),w=f(u.top,0),b=f(u.bottom,0),v={height:a.floating.height-(["left","right"].includes(i)?2*(0!==w||0!==b?w+b:f(u.top,u.bottom)):u[d]),width:a.floating.width-(["top","bottom"].includes(i)?2*(0!==y||0!==x?y+x:f(u.left,u.right)):u[h])};return null==c||c({...v,...a}),{data:{skip:!0},reset:{rects:!0}}}}},B=function(e){return void 0===e&&(e={}),{name:"inline",options:e,async fn(r){var o,i;const{placement:s,elements:m,rects:u,platform:p,strategy:g,middlewareData:d}=r,{padding:h=2,x:y,y:x}=e;if(null!=(o=d.inline)&&o.skip)return{};const w=l(await p.convertOffsetParentRelativeRectToViewportRelativeRect({rect:u.reference,offsetParent:await p.getOffsetParent({element:m.floating}),strategy:g})),b=Array.from(null!=(i=await(null==p.getClientRects?void 0:p.getClientRects({element:m.reference})))?i:[]),v=a(h);return{data:{skip:!0},reset:{rects:await p.getElementRects({reference:{getBoundingClientRect:function(){var e;if(2===b.length&&b[0].left>b[1].right&&null!=y&&null!=x)return null!=(e=b.find((t=>y>t.left-v.left&&y<t.right+v.right&&x>t.top-v.top&&x<t.bottom+v.bottom)))?e:w;if(b.length>=2){if("x"===n(s)){const e=b[0],n=b[b.length-1],r="top"===t(s),o=e.top,i=n.bottom,a=r?e.left:n.left,l=r?e.right:n.right;return{top:o,bottom:i,left:a,right:l,width:l-a,height:i-o,x:a,y:o}}const e="left"===t(s),r=f(...b.map((t=>t.right))),o=c(...b.map((t=>t.left))),i=b.filter((t=>e?t.left===o:t.right===r)),a=i[0].top,l=i[i.length-1].bottom;return{top:a,bottom:l,left:o,right:r,width:r-o,height:l-a,x:o,y:a}}return w}},floating:m.floating,strategy:g})}}}}};export{u as arrow,b as autoPlacement,i as computePosition,s as detectOverflow,v as flip,k as hide,B as inline,C as limitShift,R as offset,l as rectToClientRect,O as shift,E as size};
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};

@@ -830,4 +830,4 @@ (function (global, factory) {

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

@@ -834,0 +834,0 @@ if (crossAxisCoord < limitMin) {

@@ -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]-(null!=(w=null==(b=s.offset)?void 0:b[p])?w:0)+(n?0:x.crossAxis),r=a.reference[d]+a.reference[t]+(null!=(A=null==(P=s.offset)?void 0:P[p])?A:0)-(n?x.crossAxis:0);h<o?h=o:h>r&&(h=r)}return{[p]:g,[d]:h}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,fn(n){const{x:r,y:i,placement:l,rects:a}=n,s=function(t){let{placement:n,rects:r,value:i}=t;const l=e(n),a=["left","top"].includes(l)?-1:1,s="function"==typeof i?i({...r,placement:n}):i,{mainAxis:c,crossAxis:f}="number"==typeof s?{mainAxis:s,crossAxis:0}:{mainAxis:0,crossAxis:0,...s};return"x"===o(l)?{x:f,y:c*a}:{x:c*a,y:f}}({placement:l,rects:a,value:t});return{x:r+s.x,y:i+s.y,data:s}}}},t.rectToClientRect=a,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(n){const{x:r,y:i,placement:l}=n,{mainAxis:a=!0,crossAxis:c=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...m}=t,p={x:r,y:i},d=await s(n,m),g=o(e(l)),h=v(g);let y=p[g],x=p[h];if(a){const t="y"===g?"bottom":"right";y=u(y+d["y"===g?"top":"left"],y,y-d[t])}if(c){const t="y"===h?"bottom":"right";x=u(x+d["y"===h?"top":"left"],x,x-d[t])}const w=f.fn({...n,[g]:y,[h]:x});return{...w,data:{x:w.x-r,y:w.y-i}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(o){var r;const{placement:i,rects:l,middlewareData:a}=o,{apply:c,...u}=t;if(null!=(r=a.size)&&r.skip)return{};const m=await s(o,u),p=e(i),d="end"===n(i);let g,h;"top"===p||"bottom"===p?(g=p,h=d?"left":"right"):(h=p,g=d?"top":"bottom");const y=f(m.left,0),x=f(m.right,0),w=f(m.top,0),b=f(m.bottom,0),v={height:l.floating.height-(["left","right"].includes(i)?2*(0!==w||0!==b?w+b:f(m.top,m.bottom)):m[g]),width:l.floating.width-(["top","bottom"].includes(i)?2*(0!==y||0!==x?y+x:f(m.left,m.right)):m[h])};return null==c||c({...v,...l}),{data:{skip:!0},reset:{rects:!0}}}}},Object.defineProperty(t,"__esModule",{value:!0})}));
!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})}));
{
"name": "@floating-ui/core",
"version": "0.3.0",
"version": "0.3.1",
"@rollingversions": {

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

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