@floating-ui/core
Advanced tools
@@ -1,1 +0,1 @@ | ||
| const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce(((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1])),[]),r=Math.min,o=Math.max,i={left:"right",right:"left",bottom:"top",top:"bottom"},a={start:"end",end:"start"};function l(t,e,n){return o(t,r(e,n))}function s(t,e){return"function"==typeof t?t(e):t}function c(t){return t.split("-")[0]}function f(t){return t.split("-")[1]}function m(t){return"x"===t?"y":"x"}function u(t){return"y"===t?"height":"width"}const d=new Set(["top","bottom"]);function g(t){return d.has(c(t))?"y":"x"}function p(t){return m(g(t))}function h(t,e,n){void 0===n&&(n=!1);const r=f(t),o=p(t),i=u(o);let a="x"===o?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return e.reference[i]>e.floating[i]&&(a=R(a)),[a,R(a)]}function y(t){return t.replace(/start|end/g,(t=>a[t]))}const w=["left","right"],x=["right","left"],v=["top","bottom"],b=["bottom","top"];function A(t,e,n,r){const o=f(t);let i=function(t,e,n){switch(t){case"top":case"bottom":return n?e?x:w:e?w:x;case"left":case"right":return e?v:b;default:return[]}}(c(t),"start"===n,r);return o&&(i=i.map((t=>t+"-"+o)),e&&(i=i.concat(i.map(y)))),i}function R(t){return t.replace(/left|right|bottom|top/g,(t=>i[t]))}function O(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 D(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function P(t,e,n){let{reference:r,floating:o}=t;const i=g(e),a=p(e),l=u(a),s=c(e),m="y"===i,d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,y=r[l]/2-o[l]/2;let w;switch(s){case"top":w={x:d,y:r.y-o.height};break;case"bottom":w={x:d,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:h};break;case"left":w={x:r.x-o.width,y:h};break;default:w={x:r.x,y:r.y}}switch(f(e)){case"start":w[a]-=y*(n&&m?-1:1);break;case"end":w[a]+=y*(n&&m?-1:1)}return w}async function E(t,e){var n;void 0===e&&(e={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:g=0}=s(e,t),p=O(g),h=l[d?"floating"===u?"reference":"floating":u],y=D(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(h)))||n?h:h.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:m,strategy:c})),w="floating"===u?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),v=await(null==i.isElement?void 0:i.isElement(x))&&await(null==i.getScale?void 0:i.getScale(x))||{x:1,y:1},b=D(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:c}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}const T=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),s=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:f,y:m}=P(c,r,s),u=r,d={},g=0;for(let n=0;n<l.length;n++){var p;const{name:i,fn:h}=l[n],{x:y,y:w,data:x,reset:v}=await h({x:f,y:m,initialPlacement:r,placement:u,strategy:o,middlewareData:d,rects:c,platform:{...a,detectOverflow:null!=(p=a.detectOverflow)?p:E},elements:{reference:t,floating:e}});f=null!=y?y:f,m=null!=w?w:m,d={...d,[i]:{...d[i],...x}},v&&g<=50&&(g++,"object"==typeof v&&(v.placement&&(u=v.placement),v.rects&&(c=!0===v.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):v.rects),({x:f,y:m}=P(c,u,s))),n=-1)}return{x:f,y:m,placement:u,strategy:o,middlewareData:d}},L=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:a,platform:c,elements:m,middlewareData:d}=e,{element:g,padding:h=0}=s(t,e)||{};if(null==g)return{};const y=O(h),w={x:n,y:o},x=p(i),v=u(x),b=await c.getDimensions(g),A="y"===x,R=A?"top":"left",D=A?"bottom":"right",P=A?"clientHeight":"clientWidth",E=a.reference[v]+a.reference[x]-w[x]-a.floating[v],T=w[x]-a.reference[x],L=await(null==c.getOffsetParent?void 0:c.getOffsetParent(g));let k=L?L[P]:0;k&&await(null==c.isElement?void 0:c.isElement(L))||(k=m.floating[P]||a.floating[v]);const B=E/2-T/2,C=k/2-b[v]/2-1,H=r(y[R],C),S=r(y[D],C),F=H,M=k-b[v]-S,V=k/2-b[v]/2+B,W=l(F,V,M),j=!d.arrow&&null!=f(i)&&V!==W&&a.reference[v]/2-(V<F?H:S)-b[v]/2<0,z=j?V<F?V-F:V-M:0;return{[x]:w[x]+z,data:{[x]:W,centerOffset:V-W-z,...j&&{alignmentOffset:z}},reset:j}}});const k=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,o,i;const{rects:a,middlewareData:l,placement:m,platform:u,elements:d}=e,{crossAxis:g=!1,alignment:p,allowedPlacements:w=n,autoAlignment:x=!0,...v}=s(t,e),b=void 0!==p||w===n?function(t,e,n){return(t?[...n.filter((e=>f(e)===t)),...n.filter((e=>f(e)!==t))]:n.filter((t=>c(t)===t))).filter((n=>!t||f(n)===t||!!e&&y(n)!==n))}(p||null,x,w):w,A=await u.detectOverflow(e,v),R=(null==(r=l.autoPlacement)?void 0:r.index)||0,O=b[R];if(null==O)return{};const D=h(O,a,await(null==u.isRTL?void 0:u.isRTL(d.floating)));if(m!==O)return{reset:{placement:b[0]}};const P=[A[c(O)],A[D[0]],A[D[1]]],E=[...(null==(o=l.autoPlacement)?void 0:o.overflows)||[],{placement:O,overflows:P}],T=b[R+1];if(T)return{data:{index:R+1,overflows:E},reset:{placement:T}};const L=E.map((t=>{const e=f(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(i=L.filter((t=>t[2].slice(0,f(t[0])?2:3).every((t=>t<=0))))[0])?void 0:i[0])||L[0][0];return k!==m?{data:{index:R+1,overflows:E},reset:{placement:k}}:{}}}},B=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:f,elements:m}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...b}=s(t,e);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const O=c(o),D=g(l),P=c(l)===l,E=await(null==f.isRTL?void 0:f.isRTL(m.floating)),T=p||(P||!v?[R(l)]:function(t){const e=R(t);return[y(t),e,y(e)]}(l)),L="none"!==x;!p&&L&&T.push(...A(l,v,x,E));const k=[l,...T],B=await f.detectOverflow(e,b),C=[];let H=(null==(r=i.flip)?void 0:r.overflows)||[];if(u&&C.push(B[O]),d){const t=h(o,a,E);C.push(B[t[0]],B[t[1]])}if(H=[...H,{placement:o,overflows:C}],!C.every((t=>t<=0))){var S,F;const t=((null==(S=i.flip)?void 0:S.index)||0)+1,e=k[t];if(e){if(!("alignment"===d&&D!==g(e))||H.every((t=>g(t.placement)!==D||t.overflows[0]>0)))return{data:{index:t,overflows:H},reset:{placement:e}}}let n=null==(F=H.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var M;const t=null==(M=H.filter((t=>{if(L){const e=g(t.placement);return e===D||"y"===e}return!0})).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:M[0];t&&(n=t);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}};function C(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function H(e){return t.some((t=>e[t]>=0))}const S=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:o="referenceHidden",...i}=s(t,e);switch(o){case"referenceHidden":{const t=C(await r.detectOverflow(e,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:H(t)}}}case"escaped":{const t=C(await r.detectOverflow(e,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:H(t)}}}default:return{}}}}};function F(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:o(...t.map((t=>t.right)))-e,height:o(...t.map((t=>t.bottom)))-n}}const M=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:a,platform:l,strategy:f}=e,{padding:m=2,x:u,y:d}=s(t,e),p=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(i.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let r=null;for(let t=0;t<e.length;t++){const o=e[t];!r||o.y-r.y>r.height/2?n.push([o]):n[n.length-1].push(o),r=o}return n.map((t=>D(F(t))))}(p),y=D(F(p)),w=O(m);const x=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=u&&null!=d)return h.find((t=>u>t.left-w.left&&u<t.right+w.right&&d>t.top-w.top&&d<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===g(n)){const t=h[0],e=h[h.length-1],r="top"===c(n),o=t.top,i=e.bottom,a=r?t.left:e.left,l=r?t.right:e.right;return{top:o,bottom:i,left:a,right:l,width:l-a,height:i-o,x:a,y:o}}const t="left"===c(n),e=o(...h.map((t=>t.right))),i=r(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===i:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:e,width:e-i,height:s-l,x:i,y:l}}return y}},floating:i.floating,strategy:f});return a.reference.x!==x.reference.x||a.reference.y!==x.reference.y||a.reference.width!==x.reference.width||a.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},V=new Set(["left","top"]);const W=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=e,m=await async function(t,e){const{placement:n,platform:r,elements:o}=t,i=await(null==r.isRTL?void 0:r.isRTL(o.floating)),a=c(n),l=f(n),m="y"===g(n),u=V.has(a)?-1:1,d=i&&m?-1:1,p=s(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&"number"==typeof w&&(y="end"===l?-1*w:w),m?{x:y*d,y:h*u}:{x:h*u,y:y*d}}(e,t);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(r=l.arrow)&&r.alignmentOffset?{}:{x:o+m.x,y:i+m.y,data:{...m,placement:a}}}}},j=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:i}=e,{mainAxis:a=!0,crossAxis:f=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...d}=s(t,e),p={x:n,y:r},h=await i.detectOverflow(e,d),y=g(c(o)),w=m(y);let x=p[w],v=p[y];if(a){const t="y"===w?"bottom":"right";x=l(x+h["y"===w?"top":"left"],x,x-h[t])}if(f){const t="y"===y?"bottom":"right";v=l(v+h["y"===y?"top":"left"],v,v-h[t])}const b=u.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[w]:a,[y]:f}}}}}},z=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=e,{offset:l=0,mainAxis:f=!0,crossAxis:u=!0}=s(t,e),d={x:n,y:r},p=g(o),h=m(p);let y=d[h],w=d[p];const x=s(l,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(f){const t="y"===h?"height":"width",e=i.reference[h]-i.floating[t]+v.mainAxis,n=i.reference[h]+i.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(u){var b,A;const t="y"===h?"width":"height",e=V.has(c(o)),n=i.reference[p]-i.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),r=i.reference[p]+i.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);w<n?w=n:w>r&&(w=r)}return{[h]:y,[p]:w}}}},q=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,i;const{placement:a,rects:l,platform:m,elements:u}=e,{apply:d=()=>{},...p}=s(t,e),h=await m.detectOverflow(e,p),y=c(a),w=f(a),x="y"===g(a),{width:v,height:b}=l.floating;let A,R;"top"===y||"bottom"===y?(A=y,R=w===(await(null==m.isRTL?void 0:m.isRTL(u.floating))?"start":"end")?"left":"right"):(R=y,A="end"===w?"top":"bottom");const O=b-h.top-h.bottom,D=v-h.left-h.right,P=r(b-h[A],O),E=r(v-h[R],D),T=!e.middlewareData.shift;let L=P,k=E;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=D),null!=(i=e.middlewareData.shift)&&i.enabled.y&&(L=O),T&&!w){const t=o(h.left,0),e=o(h.right,0),n=o(h.top,0),r=o(h.bottom,0);x?k=v-2*(0!==t||0!==e?t+e:o(h.left,h.right)):L=b-2*(0!==n||0!==r?n+r:o(h.top,h.bottom))}await d({...e,availableWidth:k,availableHeight:L});const B=await m.getDimensions(u.floating);return v!==B.width||b!==B.height?{reset:{rects:!0}}:{}}}};export{L as arrow,k as autoPlacement,T as computePosition,E as detectOverflow,B as flip,S as hide,M as inline,z as limitShift,W as offset,D as rectToClientRect,j as shift,q as size}; | ||
| const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce(((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1])),[]),r=Math.min,i=Math.max,o={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e,n){return i(t,r(e,n))}function l(t,e){return"function"==typeof t?t(e):t}function s(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function f(t){return"x"===t?"y":"x"}function m(t){return"y"===t?"height":"width"}function u(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function d(t){return f(u(t))}function g(t,e,n){void 0===n&&(n=!1);const r=c(t),i=d(t),o=m(i);let a="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return e.reference[o]>e.floating[o]&&(a=b(a)),[a,b(a)]}function p(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],y=["right","left"],w=["top","bottom"],x=["bottom","top"];function v(t,e,n,r){const i=c(t);let o=function(t,e,n){switch(t){case"top":case"bottom":return n?e?y:h:e?h:y;case"left":case"right":return e?w:x;default:return[]}}(s(t),"start"===n,r);return i&&(o=o.map((t=>t+"-"+i)),e&&(o=o.concat(o.map(p)))),o}function b(t){const e=s(t);return o[e]+t.slice(e.length)}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 R(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function O(t,e,n){let{reference:r,floating:i}=t;const o=u(e),a=d(e),l=m(a),f=s(e),g="y"===o,p=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,y=r[l]/2-i[l]/2;let w;switch(f){case"top":w={x:p,y:r.y-i.height};break;case"bottom":w={x:p,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:h};break;case"left":w={x:r.x-i.width,y:h};break;default:w={x:r.x,y:r.y}}switch(c(e)){case"start":w[a]-=y*(n&&g?-1:1);break;case"end":w[a]+=y*(n&&g?-1:1)}return w}async function D(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:o,rects:a,elements:s,strategy:c}=t,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:g=0}=l(e,t),p=A(g),h=s[d?"floating"===u?"reference":"floating":u],y=R(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(h)))||n?h:h.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:f,rootBoundary:m,strategy:c})),w="floating"===u?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,x=await(null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),v=await(null==o.isElement?void 0:o.isElement(x))&&await(null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},b=R(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:w,offsetParent:x,strategy:c}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}const P=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:D},s=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:m}=O(c,r,s),u=r,d=0;const g={};for(let n=0;n<o.length;n++){const p=o[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:f,y:m,initialPlacement:r,placement:u,strategy:i,middlewareData:g,rects:c,platform:l,elements:{reference:t,floating:e}});f=null!=w?w:f,m=null!=x?x:m,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(u=b.placement),b.rects&&(c=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:m}=O(c,u,s))),n=-1)}return{x:f,y:m,placement:u,strategy:i,middlewareData:g}},E=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:o,rects:s,platform:f,elements:u,middlewareData:g}=e,{element:p,padding:h=0}=l(t,e)||{};if(null==p)return{};const y=A(h),w={x:n,y:i},x=d(o),v=m(x),b=await f.getDimensions(p),R="y"===x,O=R?"top":"left",D=R?"bottom":"right",P=R?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[x]-w[x]-s.floating[v],T=w[x]-s.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[P]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=u.floating[P]||s.floating[v]);const C=E/2-T/2,H=k/2-b[v]/2-1,B=r(y[O],H),S=r(y[D],H),F=B,M=k-b[v]-S,V=k/2-b[v]/2+C,W=a(F,V,M),j=!g.arrow&&null!=c(o)&&V!==W&&s.reference[v]/2-(V<F?B:S)-b[v]/2<0,z=j?V<F?V-F:V-M:0;return{[x]:w[x]+z,data:{[x]:W,centerOffset:V-W-z,...j&&{alignmentOffset:z}},reset:j}}});const T=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,i,o;const{rects:a,middlewareData:f,placement:m,platform:u,elements:d}=e,{crossAxis:h=!1,alignment:y,allowedPlacements:w=n,autoAlignment:x=!0,...v}=l(t,e),b=void 0!==y||w===n?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>s(t)===t))).filter((n=>!t||c(n)===t||!!e&&p(n)!==n))}(y||null,x,w):w,A=await u.detectOverflow(e,v),R=(null==(r=f.autoPlacement)?void 0:r.index)||0,O=b[R];if(null==O)return{};const D=g(O,a,await(null==u.isRTL?void 0:u.isRTL(d.floating)));if(m!==O)return{reset:{placement:b[0]}};const P=[A[s(O)],A[D[0]],A[D[1]]],E=[...(null==(i=f.autoPlacement)?void 0:i.overflows)||[],{placement:O,overflows:P}],T=b[R+1];if(T)return{data:{index:R+1,overflows:E},reset:{placement:T}};const L=E.map((t=>{const e=c(t.placement);return[t.placement,e&&h?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(o=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:o[0])||L[0][0];return k!==m?{data:{index:R+1,overflows:E},reset:{placement:k}}:{}}}},L=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:c,platform:f,elements:m}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:A=!0,...R}=l(t,e);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const O=s(i),D=u(c),P=s(c)===c,E=await(null==f.isRTL?void 0:f.isRTL(m.floating)),T=y||(P||!A?[b(c)]:function(t){const e=b(t);return[p(t),e,p(e)]}(c)),L="none"!==x;!y&&L&&T.push(...v(c,A,x,E));const k=[c,...T],C=await f.detectOverflow(e,R),H=[];let B=(null==(r=o.flip)?void 0:r.overflows)||[];if(d&&H.push(C[O]),h){const t=g(i,a,E);H.push(C[t[0]],C[t[1]])}if(B=[...B,{placement:i,overflows:H}],!H.every((t=>t<=0))){var S,F;const t=((null==(S=o.flip)?void 0:S.index)||0)+1,e=k[t];if(e){if(!("alignment"===h&&D!==u(e))||B.every((t=>u(t.placement)!==D||t.overflows[0]>0)))return{data:{index:t,overflows:B},reset:{placement:e}}}let n=null==(F=B.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var M;const t=null==(M=B.filter((t=>{if(L){const e=u(t.placement);return e===D||"y"===e}return!0})).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:M[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}};function k(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function C(e){return t.some((t=>e[t]>=0))}const H=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...o}=l(t,e);switch(i){case"referenceHidden":{const t=k(await r.detectOverflow(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:C(t)}}}case"escaped":{const t=k(await r.detectOverflow(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:C(t)}}}default:return{}}}}};function B(t){const e=r(...t.map((t=>t.left))),n=r(...t.map((t=>t.top)));return{x:e,y:n,width:i(...t.map((t=>t.right)))-e,height:i(...t.map((t=>t.bottom)))-n}}const S=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:o,rects:a,platform:c,strategy:f}=e,{padding:m=2,x:d,y:g}=l(t,e),p=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(o.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let r=null;for(let t=0;t<e.length;t++){const i=e[t];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map((t=>R(B(t))))}(p),y=R(B(p)),w=A(m);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=d&&null!=g)return h.find((t=>d>t.left-w.left&&d<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===u(n)){const t=h[0],e=h[h.length-1],r="top"===s(n),i=t.top,o=e.bottom,a=r?t.left:e.left,l=r?t.right:e.right;return{top:i,bottom:o,left:a,right:l,width:l-a,height:o-i,x:a,y:i}}const t="left"===s(n),e=i(...h.map((t=>t.right))),o=r(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===o:n.right===e)),l=a[0].top,c=a[a.length-1].bottom;return{top:l,bottom:c,left:o,right:e,width:e-o,height:c-l,x:o,y:l}}return y}},floating:o.floating,strategy:f});return a.reference.x!==x.reference.x||a.reference.y!==x.reference.y||a.reference.width!==x.reference.width||a.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},F=new Set(["left","top"]);const M=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:o,placement:a,middlewareData:f}=e,m=await async function(t,e){const{placement:n,platform:r,elements:i}=t,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),a=s(n),f=c(n),m="y"===u(n),d=F.has(a)?-1:1,g=o&&m?-1:1,p=l(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return f&&"number"==typeof w&&(y="end"===f?-1*w:w),m?{x:y*g,y:h*d}:{x:h*d,y:y*g}}(e,t);return a===(null==(n=f.offset)?void 0:n.placement)&&null!=(r=f.arrow)&&r.alignmentOffset?{}:{x:i+m.x,y:o+m.y,data:{...m,placement:a}}}}},V=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:o}=e,{mainAxis:c=!0,crossAxis:m=!1,limiter:d={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...g}=l(t,e),p={x:n,y:r},h=await o.detectOverflow(e,g),y=u(s(i)),w=f(y);let x=p[w],v=p[y];if(c){const t="y"===w?"bottom":"right";x=a(x+h["y"===w?"top":"left"],x,x-h[t])}if(m){const t="y"===y?"bottom":"right";v=a(v+h["y"===y?"top":"left"],v,v-h[t])}const b=d.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[w]:c,[y]:m}}}}}},W=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=e,{offset:c=0,mainAxis:m=!0,crossAxis:d=!0}=l(t,e),g={x:n,y:r},p=u(i),h=f(p);let y=g[h],w=g[p];const x=l(c,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(m){const t="y"===h?"height":"width",e=o.reference[h]-o.floating[t]+v.mainAxis,n=o.reference[h]+o.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(d){var b,A;const t="y"===h?"width":"height",e=F.has(s(i)),n=o.reference[p]-o.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),r=o.reference[p]+o.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);w<n?w=n:w>r&&(w=r)}return{[h]:y,[p]:w}}}},j=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,o;const{placement:a,rects:f,platform:m,elements:d}=e,{apply:g=()=>{},...p}=l(t,e),h=await m.detectOverflow(e,p),y=s(a),w=c(a),x="y"===u(a),{width:v,height:b}=f.floating;let A,R;"top"===y||"bottom"===y?(A=y,R=w===(await(null==m.isRTL?void 0:m.isRTL(d.floating))?"start":"end")?"left":"right"):(R=y,A="end"===w?"top":"bottom");const O=b-h.top-h.bottom,D=v-h.left-h.right,P=r(b-h[A],O),E=r(v-h[R],D),T=!e.middlewareData.shift;let L=P,k=E;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=D),null!=(o=e.middlewareData.shift)&&o.enabled.y&&(L=O),T&&!w){const t=i(h.left,0),e=i(h.right,0),n=i(h.top,0),r=i(h.bottom,0);x?k=v-2*(0!==t||0!==e?t+e:i(h.left,h.right)):L=b-2*(0!==n||0!==r?n+r:i(h.top,h.bottom))}await g({...e,availableWidth:k,availableHeight:L});const C=await m.getDimensions(d.floating);return v!==C.width||b!==C.height?{reset:{rects:!0}}:{}}}};export{E as arrow,T as autoPlacement,P as computePosition,D as detectOverflow,L as flip,H as hide,S as inline,W as limitShift,M as offset,R as rectToClientRect,V as shift,j as size}; |
@@ -17,6 +17,2 @@ /** | ||
| }; | ||
| const oppositeAlignmentMap = { | ||
| start: 'end', | ||
| end: 'start' | ||
| }; | ||
| function clamp(start, value, end) { | ||
@@ -40,5 +36,5 @@ return max(start, min(value, end)); | ||
| } | ||
| const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']); | ||
| function getSideAxis(placement) { | ||
| return yAxisSides.has(getSide(placement)) ? 'y' : 'x'; | ||
| const firstChar = placement[0]; | ||
| return firstChar === 't' || firstChar === 'b' ? 'y' : 'x'; | ||
| } | ||
@@ -66,3 +62,3 @@ function getAlignmentAxis(placement) { | ||
| function getOppositeAlignmentPlacement(placement) { | ||
| return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]); | ||
| return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start'); | ||
| } | ||
@@ -98,3 +94,4 @@ const lrPlacement = ['left', 'right']; | ||
| function getOppositePlacement(placement) { | ||
| return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]); | ||
| const side = getSide(placement); | ||
| return oppositeSideMap[side] + placement.slice(side.length); | ||
| } | ||
@@ -258,2 +255,5 @@ function expandPaddingObject(padding) { | ||
| // Maximum number of resets that can occur before bailing to avoid infinite reset loops. | ||
| const MAX_RESET_COUNT = 50; | ||
| /** | ||
@@ -273,3 +273,6 @@ * Computes the `x` and `y` coordinates that will place the floating element | ||
| } = config; | ||
| const validMiddleware = middleware.filter(Boolean); | ||
| const platformWithDetectOverflow = platform.detectOverflow ? platform : { | ||
| ...platform, | ||
| detectOverflow | ||
| }; | ||
| const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); | ||
@@ -286,10 +289,13 @@ let rects = await platform.getElementRects({ | ||
| let statefulPlacement = placement; | ||
| let middlewareData = {}; | ||
| let resetCount = 0; | ||
| for (let i = 0; i < validMiddleware.length; i++) { | ||
| var _platform$detectOverf; | ||
| const middlewareData = {}; | ||
| for (let i = 0; i < middleware.length; i++) { | ||
| const currentMiddleware = middleware[i]; | ||
| if (!currentMiddleware) { | ||
| continue; | ||
| } | ||
| const { | ||
| name, | ||
| fn | ||
| } = validMiddleware[i]; | ||
| } = currentMiddleware; | ||
| const { | ||
@@ -308,6 +314,3 @@ x: nextX, | ||
| rects, | ||
| platform: { | ||
| ...platform, | ||
| detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow | ||
| }, | ||
| platform: platformWithDetectOverflow, | ||
| elements: { | ||
@@ -320,10 +323,7 @@ reference, | ||
| y = nextY != null ? nextY : y; | ||
| middlewareData = { | ||
| ...middlewareData, | ||
| [name]: { | ||
| ...middlewareData[name], | ||
| ...data | ||
| } | ||
| middlewareData[name] = { | ||
| ...middlewareData[name], | ||
| ...data | ||
| }; | ||
| if (reset && resetCount <= 50) { | ||
| if (reset && resetCount < MAX_RESET_COUNT) { | ||
| resetCount++; | ||
@@ -330,0 +330,0 @@ if (typeof reset === 'object') { |
@@ -125,2 +125,5 @@ import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils'; | ||
| // Maximum number of resets that can occur before bailing to avoid infinite reset loops. | ||
| const MAX_RESET_COUNT = 50; | ||
| /** | ||
@@ -140,3 +143,6 @@ * Computes the `x` and `y` coordinates that will place the floating element | ||
| } = config; | ||
| const validMiddleware = middleware.filter(Boolean); | ||
| const platformWithDetectOverflow = platform.detectOverflow ? platform : { | ||
| ...platform, | ||
| detectOverflow | ||
| }; | ||
| const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); | ||
@@ -153,10 +159,13 @@ let rects = await platform.getElementRects({ | ||
| let statefulPlacement = placement; | ||
| let middlewareData = {}; | ||
| let resetCount = 0; | ||
| for (let i = 0; i < validMiddleware.length; i++) { | ||
| var _platform$detectOverf; | ||
| const middlewareData = {}; | ||
| for (let i = 0; i < middleware.length; i++) { | ||
| const currentMiddleware = middleware[i]; | ||
| if (!currentMiddleware) { | ||
| continue; | ||
| } | ||
| const { | ||
| name, | ||
| fn | ||
| } = validMiddleware[i]; | ||
| } = currentMiddleware; | ||
| const { | ||
@@ -175,6 +184,3 @@ x: nextX, | ||
| rects, | ||
| platform: { | ||
| ...platform, | ||
| detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow | ||
| }, | ||
| platform: platformWithDetectOverflow, | ||
| elements: { | ||
@@ -187,10 +193,7 @@ reference, | ||
| y = nextY != null ? nextY : y; | ||
| middlewareData = { | ||
| ...middlewareData, | ||
| [name]: { | ||
| ...middlewareData[name], | ||
| ...data | ||
| } | ||
| middlewareData[name] = { | ||
| ...middlewareData[name], | ||
| ...data | ||
| }; | ||
| if (reset && resetCount <= 50) { | ||
| if (reset && resetCount < MAX_RESET_COUNT) { | ||
| resetCount++; | ||
@@ -197,0 +200,0 @@ if (typeof reset === 'object') { |
@@ -125,2 +125,5 @@ import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils'; | ||
| // Maximum number of resets that can occur before bailing to avoid infinite reset loops. | ||
| const MAX_RESET_COUNT = 50; | ||
| /** | ||
@@ -140,3 +143,6 @@ * Computes the `x` and `y` coordinates that will place the floating element | ||
| } = config; | ||
| const validMiddleware = middleware.filter(Boolean); | ||
| const platformWithDetectOverflow = platform.detectOverflow ? platform : { | ||
| ...platform, | ||
| detectOverflow | ||
| }; | ||
| const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); | ||
@@ -153,10 +159,13 @@ let rects = await platform.getElementRects({ | ||
| let statefulPlacement = placement; | ||
| let middlewareData = {}; | ||
| let resetCount = 0; | ||
| for (let i = 0; i < validMiddleware.length; i++) { | ||
| var _platform$detectOverf; | ||
| const middlewareData = {}; | ||
| for (let i = 0; i < middleware.length; i++) { | ||
| const currentMiddleware = middleware[i]; | ||
| if (!currentMiddleware) { | ||
| continue; | ||
| } | ||
| const { | ||
| name, | ||
| fn | ||
| } = validMiddleware[i]; | ||
| } = currentMiddleware; | ||
| const { | ||
@@ -175,6 +184,3 @@ x: nextX, | ||
| rects, | ||
| platform: { | ||
| ...platform, | ||
| detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow | ||
| }, | ||
| platform: platformWithDetectOverflow, | ||
| elements: { | ||
@@ -187,10 +193,7 @@ reference, | ||
| y = nextY != null ? nextY : y; | ||
| middlewareData = { | ||
| ...middlewareData, | ||
| [name]: { | ||
| ...middlewareData[name], | ||
| ...data | ||
| } | ||
| middlewareData[name] = { | ||
| ...middlewareData[name], | ||
| ...data | ||
| }; | ||
| if (reset && resetCount <= 50) { | ||
| if (reset && resetCount < MAX_RESET_COUNT) { | ||
| resetCount++; | ||
@@ -197,0 +200,0 @@ if (typeof reset === 'object') { |
@@ -23,6 +23,2 @@ (function (global, factory) { | ||
| }; | ||
| const oppositeAlignmentMap = { | ||
| start: 'end', | ||
| end: 'start' | ||
| }; | ||
| function clamp(start, value, end) { | ||
@@ -46,5 +42,5 @@ return max(start, min(value, end)); | ||
| } | ||
| const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']); | ||
| function getSideAxis(placement) { | ||
| return yAxisSides.has(getSide(placement)) ? 'y' : 'x'; | ||
| const firstChar = placement[0]; | ||
| return firstChar === 't' || firstChar === 'b' ? 'y' : 'x'; | ||
| } | ||
@@ -72,3 +68,3 @@ function getAlignmentAxis(placement) { | ||
| function getOppositeAlignmentPlacement(placement) { | ||
| return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]); | ||
| return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start'); | ||
| } | ||
@@ -104,3 +100,4 @@ const lrPlacement = ['left', 'right']; | ||
| function getOppositePlacement(placement) { | ||
| return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]); | ||
| const side = getSide(placement); | ||
| return oppositeSideMap[side] + placement.slice(side.length); | ||
| } | ||
@@ -264,2 +261,5 @@ function expandPaddingObject(padding) { | ||
| // Maximum number of resets that can occur before bailing to avoid infinite reset loops. | ||
| const MAX_RESET_COUNT = 50; | ||
| /** | ||
@@ -279,3 +279,6 @@ * Computes the `x` and `y` coordinates that will place the floating element | ||
| } = config; | ||
| const validMiddleware = middleware.filter(Boolean); | ||
| const platformWithDetectOverflow = platform.detectOverflow ? platform : { | ||
| ...platform, | ||
| detectOverflow | ||
| }; | ||
| const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); | ||
@@ -292,10 +295,13 @@ let rects = await platform.getElementRects({ | ||
| let statefulPlacement = placement; | ||
| let middlewareData = {}; | ||
| let resetCount = 0; | ||
| for (let i = 0; i < validMiddleware.length; i++) { | ||
| var _platform$detectOverf; | ||
| const middlewareData = {}; | ||
| for (let i = 0; i < middleware.length; i++) { | ||
| const currentMiddleware = middleware[i]; | ||
| if (!currentMiddleware) { | ||
| continue; | ||
| } | ||
| const { | ||
| name, | ||
| fn | ||
| } = validMiddleware[i]; | ||
| } = currentMiddleware; | ||
| const { | ||
@@ -314,6 +320,3 @@ x: nextX, | ||
| rects, | ||
| platform: { | ||
| ...platform, | ||
| detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow | ||
| }, | ||
| platform: platformWithDetectOverflow, | ||
| elements: { | ||
@@ -326,10 +329,7 @@ reference, | ||
| y = nextY != null ? nextY : y; | ||
| middlewareData = { | ||
| ...middlewareData, | ||
| [name]: { | ||
| ...middlewareData[name], | ||
| ...data | ||
| } | ||
| middlewareData[name] = { | ||
| ...middlewareData[name], | ||
| ...data | ||
| }; | ||
| if (reset && resetCount <= 50) { | ||
| if (reset && resetCount < MAX_RESET_COUNT) { | ||
| resetCount++; | ||
@@ -336,0 +336,0 @@ if (typeof reset === 'object') { |
@@ -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";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),o=Math.min,r=Math.max,a={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function s(t,e,n){return r(t,o(e,n))}function f(t,e){return"function"==typeof t?t(e):t}function c(t){return t.split("-")[0]}function m(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function d(t){return"y"===t?"height":"width"}const g=new Set(["top","bottom"]);function p(t){return g.has(c(t))?"y":"x"}function h(t){return u(p(t))}function y(t,e,n){void 0===n&&(n=!1);const i=m(t),o=h(t),r=d(o);let a="x"===o?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=O(a)),[a,O(a)]}function w(t){return t.replace(/start|end/g,(t=>l[t]))}const x=["left","right"],v=["right","left"],b=["top","bottom"],A=["bottom","top"];function R(t,e,n,i){const o=m(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?v:x:e?x:v;case"left":case"right":return e?b:A;default:return[]}}(c(t),"start"===n,i);return o&&(r=r.map((t=>t+"-"+o)),e&&(r=r.concat(r.map(w)))),r}function O(t){return t.replace(/left|right|bottom|top/g,(t=>a[t]))}function P(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 D(t){const{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function T(t,e,n){let{reference:i,floating:o}=t;const r=p(e),a=h(e),l=d(a),s=c(e),f="y"===r,u=i.x+i.width/2-o.width/2,g=i.y+i.height/2-o.height/2,y=i[l]/2-o[l]/2;let w;switch(s){case"top":w={x:u,y:i.y-o.height};break;case"bottom":w={x:u,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:g};break;case"left":w={x:i.x-o.width,y:g};break;default:w={x:i.x,y:i.y}}switch(m(e)){case"start":w[a]-=y*(n&&f?-1:1);break;case"end":w[a]+=y*(n&&f?-1:1)}return w}async function E(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:a,elements:l,strategy:s}=t,{boundary:c="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:g=0}=f(e,t),p=P(g),h=l[d?"floating"===u?"reference":"floating":u],y=D(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(h)))||n?h:h.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:m,strategy:s})),w="floating"===u?{x:i,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(l.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=D(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:s}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}function L(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function k(t){return e.some((e=>t[e]>=0))}function C(t){const e=o(...t.map((t=>t.left))),n=o(...t.map((t=>t.top)));return{x:e,y:n,width:r(...t.map((t=>t.right)))-e,height:r(...t.map((t=>t.bottom)))-n}}const S=new Set(["left","top"]);t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:a,platform:l,elements:c,middlewareData:u}=e,{element:g,padding:p=0}=f(t,e)||{};if(null==g)return{};const y=P(p),w={x:n,y:i},x=h(r),v=d(x),b=await l.getDimensions(g),A="y"===x,R=A?"top":"left",O=A?"bottom":"right",D=A?"clientHeight":"clientWidth",T=a.reference[v]+a.reference[x]-w[x]-a.floating[v],E=w[x]-a.reference[x],L=await(null==l.getOffsetParent?void 0:l.getOffsetParent(g));let k=L?L[D]:0;k&&await(null==l.isElement?void 0:l.isElement(L))||(k=c.floating[D]||a.floating[v]);const C=T/2-E/2,S=k/2-b[v]/2-1,B=o(y[R],S),H=o(y[O],S),F=B,j=k-b[v]-H,z=k/2-b[v]/2+C,M=s(F,z,j),V=!u.arrow&&null!=m(r)&&z!==M&&a.reference[v]/2-(z<F?B:H)-b[v]/2<0,W=V?z<F?z-F:z-j:0;return{[x]:w[x]+W,data:{[x]:M,centerOffset:z-M-W,...V&&{alignmentOffset:W}},reset:V}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,r;const{rects:a,middlewareData:l,placement:s,platform:u,elements:d}=e,{crossAxis:g=!1,alignment:p,allowedPlacements:h=i,autoAlignment:x=!0,...v}=f(t,e),b=void 0!==p||h===i?function(t,e,n){return(t?[...n.filter((e=>m(e)===t)),...n.filter((e=>m(e)!==t))]:n.filter((t=>c(t)===t))).filter((n=>!t||m(n)===t||!!e&&w(n)!==n))}(p||null,x,h):h,A=await u.detectOverflow(e,v),R=(null==(n=l.autoPlacement)?void 0:n.index)||0,O=b[R];if(null==O)return{};const P=y(O,a,await(null==u.isRTL?void 0:u.isRTL(d.floating)));if(s!==O)return{reset:{placement:b[0]}};const D=[A[c(O)],A[P[0]],A[P[1]]],T=[...(null==(o=l.autoPlacement)?void 0:o.overflows)||[],{placement:O,overflows:D}],E=b[R+1];if(E)return{data:{index:R+1,overflows:T},reset:{placement:E}};const L=T.map((t=>{const e=m(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(r=L.filter((t=>t[2].slice(0,m(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||L[0][0];return k!==s?{data:{index:R+1,overflows:T},reset:{placement:k}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n,l=r.filter(Boolean),s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:m}=T(f,i,s),u=i,d={},g=0;for(let n=0;n<l.length;n++){var p;const{name:r,fn:h}=l[n],{x:y,y:w,data:x,reset:v}=await h({x:c,y:m,initialPlacement:i,placement:u,strategy:o,middlewareData:d,rects:f,platform:{...a,detectOverflow:null!=(p=a.detectOverflow)?p:E},elements:{reference:t,floating:e}});c=null!=y?y:c,m=null!=w?w:m,d={...d,[r]:{...d[r],...x}},v&&g<=50&&(g++,"object"==typeof v&&(v.placement&&(u=v.placement),v.rects&&(f=!0===v.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):v.rects),({x:c,y:m}=T(f,u,s))),n=-1)}return{x:c,y:m,placement:u,strategy:o,middlewareData:d}},t.detectOverflow=E,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:o,middlewareData:r,rects:a,initialPlacement:l,platform:s,elements:m}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:g,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...b}=f(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const A=c(o),P=p(l),D=c(l)===l,T=await(null==s.isRTL?void 0:s.isRTL(m.floating)),E=g||(D||!v?[O(l)]:function(t){const e=O(t);return[w(t),e,w(e)]}(l)),L="none"!==x;!g&&L&&E.push(...R(l,v,x,T));const k=[l,...E],C=await s.detectOverflow(e,b),S=[];let B=(null==(i=r.flip)?void 0:i.overflows)||[];if(u&&S.push(C[A]),d){const t=y(o,a,T);S.push(C[t[0]],C[t[1]])}if(B=[...B,{placement:o,overflows:S}],!S.every((t=>t<=0))){var H,F;const t=((null==(H=r.flip)?void 0:H.index)||0)+1,e=k[t];if(e){if(!("alignment"===d&&P!==p(e))||B.every((t=>p(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:B},reset:{placement:e}}}let n=null==(F=B.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(h){case"bestFit":{var j;const t=null==(j=B.filter((t=>{if(L){const e=p(t.placement);return e===P||"y"===e}return!0})).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:j[0];t&&(n=t);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:o="referenceHidden",...r}=f(t,e);switch(o){case"referenceHidden":{const t=L(await i.detectOverflow(e,{...r,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:k(t)}}}case"escaped":{const t=L(await i.detectOverflow(e,{...r,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:k(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:a,platform:l,strategy:s}=e,{padding:m=2,x:u,y:d}=f(t,e),g=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(i.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;t<e.length;t++){const o=e[t];!i||o.y-i.y>i.height/2?n.push([o]):n[n.length-1].push(o),i=o}return n.map((t=>D(C(t))))}(g),y=D(C(g)),w=P(m);const x=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=u&&null!=d)return h.find((t=>u>t.left-w.left&&u<t.right+w.right&&d>t.top-w.top&&d<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===p(n)){const t=h[0],e=h[h.length-1],i="top"===c(n),o=t.top,r=e.bottom,a=i?t.left:e.left,l=i?t.right:e.right;return{top:o,bottom:r,left:a,right:l,width:l-a,height:r-o,x:a,y:o}}const t="left"===c(n),e=r(...h.map((t=>t.right))),i=o(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===i:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:e,width:e-i,height:s-l,x:i,y:l}}return y}},floating:i.floating,strategy:s});return a.reference.x!==x.reference.x||a.reference.y!==x.reference.y||a.reference.width!==x.reference.width||a.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:i,placement:o,rects:r,middlewareData:a}=e,{offset:l=0,mainAxis:s=!0,crossAxis:m=!0}=f(t,e),d={x:n,y:i},g=p(o),h=u(g);let y=d[h],w=d[g];const x=f(l,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(s){const t="y"===h?"height":"width",e=r.reference[h]-r.floating[t]+v.mainAxis,n=r.reference[h]+r.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(m){var b,A;const t="y"===h?"width":"height",e=S.has(c(o)),n=r.reference[g]-r.floating[t]+(e&&(null==(b=a.offset)?void 0:b[g])||0)+(e?0:v.crossAxis),i=r.reference[g]+r.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[g])||0)-(e?v.crossAxis:0);w<n?w=n:w>i&&(w=i)}return{[h]:y,[g]:w}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:o,y:r,placement:a,middlewareData:l}=e,s=await async function(t,e){const{placement:n,platform:i,elements:o}=t,r=await(null==i.isRTL?void 0:i.isRTL(o.floating)),a=c(n),l=m(n),s="y"===p(n),u=S.has(a)?-1:1,d=r&&s?-1:1,g=f(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof g?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&"number"==typeof w&&(y="end"===l?-1*w:w),s?{x:y*d,y:h*u}:{x:h*u,y:y*d}}(e,t);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(i=l.arrow)&&i.alignmentOffset?{}:{x:o+s.x,y:r+s.y,data:{...s,placement:a}}}}},t.rectToClientRect=D,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:o,platform:r}=e,{mainAxis:a=!0,crossAxis:l=!1,limiter:m={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...d}=f(t,e),g={x:n,y:i},h=await r.detectOverflow(e,d),y=p(c(o)),w=u(y);let x=g[w],v=g[y];if(a){const t="y"===w?"bottom":"right";x=s(x+h["y"===w?"top":"left"],x,x-h[t])}if(l){const t="y"===y?"bottom":"right";v=s(v+h["y"===y?"top":"left"],v,v-h[t])}const b=m.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-i,enabled:{[w]:a,[y]:l}}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,i;const{placement:a,rects:l,platform:s,elements:u}=e,{apply:d=()=>{},...g}=f(t,e),h=await s.detectOverflow(e,g),y=c(a),w=m(a),x="y"===p(a),{width:v,height:b}=l.floating;let A,R;"top"===y||"bottom"===y?(A=y,R=w===(await(null==s.isRTL?void 0:s.isRTL(u.floating))?"start":"end")?"left":"right"):(R=y,A="end"===w?"top":"bottom");const O=b-h.top-h.bottom,P=v-h.left-h.right,D=o(b-h[A],O),T=o(v-h[R],P),E=!e.middlewareData.shift;let L=D,k=T;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=P),null!=(i=e.middlewareData.shift)&&i.enabled.y&&(L=O),E&&!w){const t=r(h.left,0),e=r(h.right,0),n=r(h.top,0),i=r(h.bottom,0);x?k=v-2*(0!==t||0!==e?t+e:r(h.left,h.right)):L=b-2*(0!==n||0!==i?n+i:r(h.top,h.bottom))}await d({...e,availableWidth:k,availableHeight:L});const C=await s.getDimensions(u.floating);return v!==C.width||b!==C.height?{reset:{rects:!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";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),o=Math.min,r=Math.max,a={left:"right",right:"left",bottom:"top",top:"bottom"};function l(t,e,n){return r(t,o(e,n))}function s(t,e){return"function"==typeof t?t(e):t}function f(t){return t.split("-")[0]}function c(t){return t.split("-")[1]}function m(t){return"x"===t?"y":"x"}function u(t){return"y"===t?"height":"width"}function d(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function g(t){return m(d(t))}function p(t,e,n){void 0===n&&(n=!1);const i=c(t),o=g(t),r=u(o);let a="x"===o?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=A(a)),[a,A(a)]}function h(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const y=["left","right"],w=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t,e,n,i){const o=c(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:y:e?y:w;case"left":case"right":return e?x:v;default:return[]}}(f(t),"start"===n,i);return o&&(r=r.map((t=>t+"-"+o)),e&&(r=r.concat(r.map(h)))),r}function A(t){const e=f(t);return a[e]+t.slice(e.length)}function R(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 O(t){const{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function P(t,e,n){let{reference:i,floating:o}=t;const r=d(e),a=g(e),l=u(a),s=f(e),m="y"===r,p=i.x+i.width/2-o.width/2,h=i.y+i.height/2-o.height/2,y=i[l]/2-o[l]/2;let w;switch(s){case"top":w={x:p,y:i.y-o.height};break;case"bottom":w={x:p,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:h};break;case"left":w={x:i.x-o.width,y:h};break;default:w={x:i.x,y:i.y}}switch(c(e)){case"start":w[a]-=y*(n&&m?-1:1);break;case"end":w[a]+=y*(n&&m?-1:1)}return w}async function D(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:a,elements:l,strategy:f}=t,{boundary:c="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:g=0}=s(e,t),p=R(g),h=l[d?"floating"===u?"reference":"floating":u],y=O(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(h)))||n?h:h.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:m,strategy:f})),w="floating"===u?{x:i,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(l.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=O(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:f}):w);return{top:(y.top-b.top+p.top)/v.y,bottom:(b.bottom-y.bottom+p.bottom)/v.y,left:(y.left-b.left+p.left)/v.x,right:(b.right-y.right+p.right)/v.x}}function T(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function E(t){return e.some((e=>t[e]>=0))}function L(t){const e=o(...t.map((t=>t.left))),n=o(...t.map((t=>t.top)));return{x:e,y:n,width:r(...t.map((t=>t.right)))-e,height:r(...t.map((t=>t.bottom)))-n}}const k=new Set(["left","top"]);t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:a,platform:f,elements:m,middlewareData:d}=e,{element:p,padding:h=0}=s(t,e)||{};if(null==p)return{};const y=R(h),w={x:n,y:i},x=g(r),v=u(x),b=await f.getDimensions(p),A="y"===x,O=A?"top":"left",P=A?"bottom":"right",D=A?"clientHeight":"clientWidth",T=a.reference[v]+a.reference[x]-w[x]-a.floating[v],E=w[x]-a.reference[x],L=await(null==f.getOffsetParent?void 0:f.getOffsetParent(p));let k=L?L[D]:0;k&&await(null==f.isElement?void 0:f.isElement(L))||(k=m.floating[D]||a.floating[v]);const C=T/2-E/2,H=k/2-b[v]/2-1,S=o(y[O],H),B=o(y[P],H),F=S,j=k-b[v]-B,z=k/2-b[v]/2+C,M=l(F,z,j),V=!d.arrow&&null!=c(r)&&z!==M&&a.reference[v]/2-(z<F?S:B)-b[v]/2<0,W=V?z<F?z-F:z-j:0;return{[x]:w[x]+W,data:{[x]:M,centerOffset:z-M-W,...V&&{alignmentOffset:W}},reset:V}}}),t.autoPlacement=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,r;const{rects:a,middlewareData:l,placement:m,platform:u,elements:d}=e,{crossAxis:g=!1,alignment:y,allowedPlacements:w=i,autoAlignment:x=!0,...v}=s(t,e),b=void 0!==y||w===i?function(t,e,n){return(t?[...n.filter((e=>c(e)===t)),...n.filter((e=>c(e)!==t))]:n.filter((t=>f(t)===t))).filter((n=>!t||c(n)===t||!!e&&h(n)!==n))}(y||null,x,w):w,A=await u.detectOverflow(e,v),R=(null==(n=l.autoPlacement)?void 0:n.index)||0,O=b[R];if(null==O)return{};const P=p(O,a,await(null==u.isRTL?void 0:u.isRTL(d.floating)));if(m!==O)return{reset:{placement:b[0]}};const D=[A[f(O)],A[P[0]],A[P[1]]],T=[...(null==(o=l.autoPlacement)?void 0:o.overflows)||[],{placement:O,overflows:D}],E=b[R+1];if(E)return{data:{index:R+1,overflows:T},reset:{placement:E}};const L=T.map((t=>{const e=c(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),k=(null==(r=L.filter((t=>t[2].slice(0,c(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||L[0][0];return k!==m?{data:{index:R+1,overflows:T},reset:{placement:k}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:D},s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:m}=P(f,i,s),u=i,d=0;const g={};for(let n=0;n<r.length;n++){const p=r[n];if(!p)continue;const{name:h,fn:y}=p,{x:w,y:x,data:v,reset:b}=await y({x:c,y:m,initialPlacement:i,placement:u,strategy:o,middlewareData:g,rects:f,platform:l,elements:{reference:t,floating:e}});c=null!=w?w:c,m=null!=x?x:m,g[h]={...g[h],...v},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(u=b.placement),b.rects&&(f=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:o}):b.rects),({x:c,y:m}=P(f,u,s))),n=-1)}return{x:c,y:m,placement:u,strategy:o,middlewareData:g}},t.detectOverflow=D,t.flip=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:o,middlewareData:r,rects:a,initialPlacement:l,platform:c,elements:m}=e,{mainAxis:u=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...R}=s(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const O=f(o),P=d(l),D=f(l)===l,T=await(null==c.isRTL?void 0:c.isRTL(m.floating)),E=y||(D||!v?[A(l)]:function(t){const e=A(t);return[h(t),e,h(e)]}(l)),L="none"!==x;!y&&L&&E.push(...b(l,v,x,T));const k=[l,...E],C=await c.detectOverflow(e,R),H=[];let S=(null==(i=r.flip)?void 0:i.overflows)||[];if(u&&H.push(C[O]),g){const t=p(o,a,T);H.push(C[t[0]],C[t[1]])}if(S=[...S,{placement:o,overflows:H}],!H.every((t=>t<=0))){var B,F;const t=((null==(B=r.flip)?void 0:B.index)||0)+1,e=k[t];if(e){if(!("alignment"===g&&P!==d(e))||S.every((t=>d(t.placement)!==P||t.overflows[0]>0)))return{data:{index:t,overflows:S},reset:{placement:e}}}let n=null==(F=S.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:F.placement;if(!n)switch(w){case"bestFit":{var j;const t=null==(j=S.filter((t=>{if(L){const e=d(t.placement);return e===P||"y"===e}return!0})).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:j[0];t&&(n=t);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:o="referenceHidden",...r}=s(t,e);switch(o){case"referenceHidden":{const t=T(await i.detectOverflow(e,{...r,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:E(t)}}}case"escaped":{const t=T(await i.detectOverflow(e,{...r,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:E(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:a,platform:l,strategy:c}=e,{padding:m=2,x:u,y:g}=s(t,e),p=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(i.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;t<e.length;t++){const o=e[t];!i||o.y-i.y>i.height/2?n.push([o]):n[n.length-1].push(o),i=o}return n.map((t=>O(L(t))))}(p),y=O(L(p)),w=R(m);const x=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=u&&null!=g)return h.find((t=>u>t.left-w.left&&u<t.right+w.right&&g>t.top-w.top&&g<t.bottom+w.bottom))||y;if(h.length>=2){if("y"===d(n)){const t=h[0],e=h[h.length-1],i="top"===f(n),o=t.top,r=e.bottom,a=i?t.left:e.left,l=i?t.right:e.right;return{top:o,bottom:r,left:a,right:l,width:l-a,height:r-o,x:a,y:o}}const t="left"===f(n),e=r(...h.map((t=>t.right))),i=o(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===i:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:e,width:e-i,height:s-l,x:i,y:l}}return y}},floating:i.floating,strategy:c});return a.reference.x!==x.reference.x||a.reference.y!==x.reference.y||a.reference.width!==x.reference.width||a.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:i,placement:o,rects:r,middlewareData:a}=e,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=s(t,e),g={x:n,y:i},p=d(o),h=m(p);let y=g[h],w=g[p];const x=s(l,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const t="y"===h?"height":"width",e=r.reference[h]-r.floating[t]+v.mainAxis,n=r.reference[h]+r.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(u){var b,A;const t="y"===h?"width":"height",e=k.has(f(o)),n=r.reference[p]-r.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),i=r.reference[p]+r.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);w<n?w=n:w>i&&(w=i)}return{[h]:y,[p]:w}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:o,y:r,placement:a,middlewareData:l}=e,m=await async function(t,e){const{placement:n,platform:i,elements:o}=t,r=await(null==i.isRTL?void 0:i.isRTL(o.floating)),a=f(n),l=c(n),m="y"===d(n),u=k.has(a)?-1:1,g=r&&m?-1:1,p=s(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&"number"==typeof w&&(y="end"===l?-1*w:w),m?{x:y*g,y:h*u}:{x:h*u,y:y*g}}(e,t);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(i=l.arrow)&&i.alignmentOffset?{}:{x:o+m.x,y:r+m.y,data:{...m,placement:a}}}}},t.rectToClientRect=O,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:o,platform:r}=e,{mainAxis:a=!0,crossAxis:c=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...g}=s(t,e),p={x:n,y:i},h=await r.detectOverflow(e,g),y=d(f(o)),w=m(y);let x=p[w],v=p[y];if(a){const t="y"===w?"bottom":"right";x=l(x+h["y"===w?"top":"left"],x,x-h[t])}if(c){const t="y"===y?"bottom":"right";v=l(v+h["y"===y?"top":"left"],v,v-h[t])}const b=u.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-i,enabled:{[w]:a,[y]:c}}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,i;const{placement:a,rects:l,platform:m,elements:u}=e,{apply:g=()=>{},...p}=s(t,e),h=await m.detectOverflow(e,p),y=f(a),w=c(a),x="y"===d(a),{width:v,height:b}=l.floating;let A,R;"top"===y||"bottom"===y?(A=y,R=w===(await(null==m.isRTL?void 0:m.isRTL(u.floating))?"start":"end")?"left":"right"):(R=y,A="end"===w?"top":"bottom");const O=b-h.top-h.bottom,P=v-h.left-h.right,D=o(b-h[A],O),T=o(v-h[R],P),E=!e.middlewareData.shift;let L=D,k=T;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=P),null!=(i=e.middlewareData.shift)&&i.enabled.y&&(L=O),E&&!w){const t=r(h.left,0),e=r(h.right,0),n=r(h.top,0),i=r(h.bottom,0);x?k=v-2*(0!==t||0!==e?t+e:r(h.left,h.right)):L=b-2*(0!==n||0!==i?n+i:r(h.top,h.bottom))}await g({...e,availableWidth:k,availableHeight:L});const C=await m.getDimensions(u.floating);return v!==C.width||b!==C.height?{reset:{rects:!0}}:{}}}}})); |
+2
-2
| { | ||
| "name": "@floating-ui/core", | ||
| "version": "1.7.4", | ||
| "version": "1.7.5", | ||
| "description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more", | ||
@@ -46,3 +46,3 @@ "publishConfig": { | ||
| "dependencies": { | ||
| "@floating-ui/utils": "^0.2.10" | ||
| "@floating-ui/utils": "^0.2.11" | ||
| }, | ||
@@ -49,0 +49,0 @@ "devDependencies": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
217318
0.07%4965
0.04%Updated