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 1.3.0 to 1.3.1

2

dist/floating-ui.core.esm.js

@@ -338,3 +338,3 @@ function getAlignment(placement) {

[axis]: offset,
centerOffset: center - offset
centerOffset: center - offset + alignmentOffset
}

@@ -341,0 +341,0 @@ };

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

[axis]: offset,
centerOffset: center - offset
centerOffset: center - offset + alignmentOffset
}

@@ -347,0 +347,0 @@ };

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";function e(t){return t.split("-")[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})}));
!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?F<S?S-F:j-F:0;return{[w]:x[w]-z,data:{[w]:M,centerOffset:F-M+z}}}}),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.3.0",
"version": "1.3.1",
"@rollingversions": {

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

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

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