| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- /**
- * Custom positioning reference element.
- * @see https://floating-ui.com/docs/virtual-elements
- */
- const t=Math.min,e=Math.max,n=Math.round,o=Math.floor,i=t=>({x:t,y:t}),r={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function c(n,o,i){return e(n,t(o,i))}function s(t,e){return"function"==typeof t?t(e):t}function a(t){return t.split("-")[0]}function f(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function d(t){return"y"===t?"height":"width"}function h(t){return["top","bottom"].includes(a(t))?"y":"x"}function m(t){return u(h(t))}function p(t){return t.replace(/start|end/g,(t=>l[t]))}function g(t){return t.replace(/left|right|bottom|top/g,(t=>r[t]))}function y(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 w(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function x(t,e,n){let{reference:o,floating:i}=t;const r=h(e),l=m(e),c=d(l),s=a(e),u="y"===r,p=o.x+o.width/2-i.width/2,g=o.y+o.height/2-i.height/2,y=o[c]/2-i[c]/2;let w;switch(s){case"top":w={x:p,y:o.y-i.height};break;case"bottom":w={x:p,y:o.y+o.height};break;case"right":w={x:o.x+o.width,y:g};break;case"left":w={x:o.x-i.width,y:g};break;default:w={x:o.x,y:o.y}}switch(f(e)){case"start":w[l]-=y*(n&&u?-1:1);break;case"end":w[l]+=y*(n&&u?-1:1)}return w}
- /**
- * Computes the `x` and `y` coordinates that will place the floating element
- * next to a given reference element.
- *
- * This export does not have any `platform` interface logic. You will need to
- * write one for the platform you are using Floating UI with.
- */
- /**
- * Resolves with an object of overflow side offsets that determine how much the
- * element is overflowing a given clipping boundary on each side.
- * - positive = overflowing the boundary by that number of pixels
- * - negative = how many pixels left before it will overflow
- * - 0 = lies flush with the boundary
- * @see https://floating-ui.com/docs/detectOverflow
- */
- async function v(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:c,strategy:a}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:m=0}=s(e,t),p=y(m),g=c[h?"floating"===d?"reference":"floating":d],x=w(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:a})),v="floating"===d?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(c.floating)),R=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},T=w(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:b,strategy:a}):v);return{top:(x.top-T.top+p.top)/R.y,bottom:(T.bottom-x.bottom+p.bottom)/R.y,left:(x.left-T.left+p.left)/R.x,right:(T.right-x.right+p.right)/R.x}}
- /**
- * Provides data to position an inner element of the floating element so that it
- * appears centered to the reference element.
- * @see https://floating-ui.com/docs/arrow
- */function b(){return"undefined"!=typeof window}function R(t){return E(t)?(t.nodeName||"").toLowerCase():"#document";
- // Mocked nodes in testing environments may not be instances of Node. By
- // returning `#document` an infinite loop won't occur.
- // https://github.com/floating-ui/floating-ui/issues/2317
- }function T(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function L(t){var e;return null==(e=(E(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function E(t){return!!b()&&(t instanceof Node||t instanceof T(t).Node)}function A(t){return!!b()&&(t instanceof Element||t instanceof T(t).Element)}function D(t){return!!b()&&(t instanceof HTMLElement||t instanceof T(t).HTMLElement)}function O(t){return!(!b()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof T(t).ShadowRoot)}function S(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function C(t){return["table","td","th"].includes(R(t))}function P(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(n){return!1}}))}function F(t){const e=k(),n=A(t)?H(t):t;
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
- return["transform","translate","scale","rotate","perspective"].some((t=>!!n[t]&&"none"!==n[t]))||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function k(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function B(t){return["html","body","#document"].includes(R(t))}function H(t){return T(t).getComputedStyle(t)}function W(t){return A(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function V(t){if("html"===R(t))return t;const e=
- // Step into the shadow DOM of the parent of a slotted node.
- t.assignedSlot||
- // DOM Element detected.
- t.parentNode||
- // ShadowRoot detected.
- O(t)&&t.host||
- // Fallback.
- L(t);return O(e)?e.host:e}function M(t){const e=V(t);return B(e)?t.ownerDocument?t.ownerDocument.body:t.body:D(e)&&S(e)?e:M(e)}function z(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=M(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=T(i);if(r){const t=N(l);return e.concat(l,l.visualViewport||[],S(i)?i:[],t&&n?z(t):[])}return e.concat(i,z(i,[],n))}function N(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function I(t){const e=H(t);
- // In testing environments, the `width` and `height` properties are empty
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
- let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=D(t),l=r?t.offsetWidth:o,c=r?t.offsetHeight:i,s=n(o)!==l||n(i)!==c;return s&&(o=l,i=c),{width:o,height:i,$:s}}function j(t){return A(t)?t:t.contextElement}function q(t){const e=j(t);if(!D(e))return i(1);const o=e.getBoundingClientRect(),{width:r,height:l,$:c}=I(e);let s=(c?n(o.width):o.width)/r,a=(c?n(o.height):o.height)/l;
- // 0, NaN, or Infinity should always fallback to 1.
- return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const X=i(0);function Y(t){const e=T(t);return k()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:X}function $(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const r=t.getBoundingClientRect(),l=j(t);let c=i(1);e&&(o?A(o)&&(c=q(o)):c=q(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==T(t))&&e}(l,n,o)?Y(l):i(0);let a=(r.left+s.x)/c.x,f=(r.top+s.y)/c.y,u=r.width/c.x,d=r.height/c.y;if(l){const t=T(l),e=o&&A(o)?T(o):o;let n=t,i=N(n);for(;i&&o&&e!==n;){const t=q(i),e=i.getBoundingClientRect(),o=H(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,f*=t.y,u*=t.x,d*=t.y,a+=r,f+=l,n=T(i),i=N(n)}}return w({width:u,height:d,x:a,y:f})}
- // If <html> has a CSS width greater than the viewport, then this will be
- // incorrect for RTL.
- function _(t,e){const n=W(t).scrollLeft;return e?e.left+n:$(L(t)).left+n}function G(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:
- // RTL <body> scrollbar.
- _(t,o)),y:o.top+e.scrollTop}}function J(t,n,o){let r;if("viewport"===n)r=function(t,e){const n=T(t),o=L(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=k();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}return{width:r,height:l,x:c,y:s}}
- // Returns the inner client rect, subtracting scrollbars if present.
- (t,o);else if("document"===n)r=
- // Gets the entire size of the scrollable document area, even extending outside
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
- function(t){const n=L(t),o=W(t),i=t.ownerDocument.body,r=e(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),l=e(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let c=-o.scrollLeft+_(t);const s=-o.scrollTop;return"rtl"===H(i).direction&&(c+=e(n.clientWidth,i.clientWidth)-r),{width:r,height:l,x:c,y:s}}(L(t));else if(A(n))r=function(t,e){const n=$(t,!0,"fixed"===e),o=n.top+t.clientTop,r=n.left+t.clientLeft,l=D(t)?q(t):i(1);return{width:t.clientWidth*l.x,height:t.clientHeight*l.y,x:r*l.x,y:o*l.y}}(n,o);else{const e=Y(t);r={x:n.x-e.x,y:n.y-e.y,width:n.width,height:n.height}}return w(r)}function K(t,e){const n=V(t);return!(n===e||!A(n)||B(n))&&("fixed"===H(n).position||K(n,e))}
- // A "clipping ancestor" is an `overflow` element with the characteristic of
- // clipping (or hiding) child elements. This returns all clipping ancestors
- // of the given element up the tree.
- function Q(t,e,n){const o=D(e),r=L(e),l="fixed"===n,c=$(t,!0,l,e);let s={scrollLeft:0,scrollTop:0};const a=i(0);if(o||!o&&!l)if(("body"!==R(e)||S(r))&&(s=W(e)),o){const t=$(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else r&&(
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
- a.x=_(r));const f=!r||o||l?i(0):G(r,s);return{x:c.left+s.scrollLeft-a.x-f.x,y:c.top+s.scrollTop-a.y-f.y,width:c.width,height:c.height}}function U(t){return"static"===H(t).position}function Z(t,e){if(!D(t)||"fixed"===H(t).position)return null;if(e)return e(t);let n=t.offsetParent;
- // Firefox returns the <html> element as the offsetParent if it's non-static,
- // while Chrome and Safari return the <body> element. The <body> element must
- // be used to perform the correct calculations even if the <html> element is
- // non-static.
- return L(t)===n&&(n=n.ownerDocument.body),n}
- // Gets the closest ancestor positioned element. Handles some edge cases,
- // such as table ancestors and cross browser bugs.
- function tt(t,e){const n=T(t);if(P(t))return n;if(!D(t)){let e=V(t);for(;e&&!B(e);){if(A(e)&&!U(e))return e;e=V(e)}return n}let o=Z(t,e);for(;o&&C(o)&&U(o);)o=Z(o,e);return o&&B(o)&&U(o)&&!F(o)?n:o||function(t){let e=V(t);for(;D(e)&&!B(e);){if(F(e))return e;if(P(e))return null;e=V(e)}return null}(t)||n}const et={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const l="fixed"===r,c=L(o),s=!!e&&P(e.floating);if(o===c||s&&l)return n;let a={scrollLeft:0,scrollTop:0},f=i(1);const u=i(0),d=D(o);if((d||!d&&!l)&&(("body"!==R(o)||S(c))&&(a=W(o)),D(o))){const t=$(o);f=q(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const h=!c||d||l?i(0):G(c,a,!0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+u.x+h.x,y:n.y*f.y-a.scrollTop*f.y+u.y+h.y}},getDocumentElement:L,getClippingRect:
- // Gets the maximum area that the element is visible in due to any number of
- // clipping ancestors.
- function(n){let{element:o,boundary:i,rootBoundary:r,strategy:l}=n;const c=[..."clippingAncestors"===i?P(o)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=z(t,[],!1).filter((t=>A(t)&&"body"!==R(t))),i=null;const r="fixed"===H(t).position;let l=r?V(t):t;
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
- for(;A(l)&&!B(l);){const e=H(l),n=F(l);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||S(l)&&!n&&K(t,l))?
- // Drop non-containing blocks.
- o=o.filter((t=>t!==l)):
- // Record last containing block for next iteration.
- i=e,l=V(l)}return e.set(t,o),o}(o,this._c):[].concat(i),r],s=c[0],a=c.reduce(((n,i)=>{const r=J(o,i,l);return n.top=e(r.top,n.top),n.right=t(r.right,n.right),n.bottom=t(r.bottom,n.bottom),n.left=e(r.left,n.left),n}),J(o,s,l));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:tt,getElementRects:async function(t){const e=this.getOffsetParent||tt,n=this.getDimensions,o=await n(t.floating);return{reference:Q(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=I(t);return{width:e,height:n}},getScale:q,isElement:A,isRTL:function(t){return"rtl"===H(t).direction}};function nt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}
- // https://samthor.au/2021/observing-dom/
- /**
- * Automatically updates the position of the floating element when necessary.
- * Should only be called when the floating element is mounted on the DOM or
- * visible on the screen.
- * @returns cleanup function that should be invoked when the floating element is
- * removed from the DOM or hidden from the screen.
- * @see https://floating-ui.com/docs/autoUpdate
- */
- function ot(n,i,r,l){void 0===l&&(l={});const{ancestorScroll:c=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:f="function"==typeof IntersectionObserver,animationFrame:u=!1}=l,d=j(n),h=c||s?[...d?z(d):[],...z(i)]:[];h.forEach((t=>{c&&t.addEventListener("scroll",r,{passive:!0}),s&&t.addEventListener("resize",r)}));const m=d&&f?function(n,i){let r,l=null;const c=L(n);function s(){var t;clearTimeout(r),null==(t=l)||t.disconnect(),l=null}return function a(f,u){void 0===f&&(f=!1),void 0===u&&(u=1),s();const d=n.getBoundingClientRect(),{left:h,top:m,width:p,height:g}=d;if(f||i(),!p||!g)return;const y={rootMargin:-o(m)+"px "+-o(c.clientWidth-(h+p))+"px "+-o(c.clientHeight-(m+g))+"px "+-o(h)+"px",threshold:e(0,t(1,u))||1};let w=!0;function x(t){const e=t[0].intersectionRatio;if(e!==u){if(!w)return a();e?a(!1,e):
- // If the reference is clipped, the ratio is 0. Throttle the refresh
- // to prevent an infinite loop of updates.
- r=setTimeout((()=>{a(!1,1e-7)}),1e3)}1!==e||nt(d,n.getBoundingClientRect())||
- // It's possible that even though the ratio is reported as 1, the
- // element is not actually fully within the IntersectionObserver's root
- // area anymore. This can happen under performance constraints. This may
- // be a bug in the browser's IntersectionObserver implementation. To
- // work around this, we compare the element's bounding rect now with
- // what it was at the time we created the IntersectionObserver. If they
- // are not equal then the element moved, so we refresh.
- a(),w=!1}
- // Older browsers don't support a `document` as the root and will throw an
- // error.
- try{l=new IntersectionObserver(x,{...y,
- // Handle <iframe>s
- root:c.ownerDocument})}catch(v){l=new IntersectionObserver(x,y)}l.observe(n)}(!0),s}(d,r):null;let p,g=-1,y=null;a&&(y=new ResizeObserver((t=>{let[e]=t;e&&e.target===d&&y&&(
- // Prevent update loops when using the `size` middleware.
- // https://github.com/floating-ui/floating-ui/issues/1740
- y.unobserve(i),cancelAnimationFrame(g),g=requestAnimationFrame((()=>{var t;null==(t=y)||t.observe(i)}))),r()})),d&&!u&&y.observe(d),y.observe(i));let w=u?$(n):null;return u&&function t(){const e=$(n);w&&!nt(w,e)&&r();w=e,p=requestAnimationFrame(t)}(),r(),()=>{var t;h.forEach((t=>{c&&t.removeEventListener("scroll",r),s&&t.removeEventListener("resize",r)})),null==m||m(),null==(t=y)||t.disconnect(),y=null,u&&cancelAnimationFrame(p)}}
- /**
- * Resolves with an object of overflow side offsets that determine how much the
- * element is overflowing a given clipping boundary on each side.
- * - positive = overflowing the boundary by that number of pixels
- * - negative = how many pixels left before it will overflow
- * - 0 = lies flush with the boundary
- * @see https://floating-ui.com/docs/detectOverflow
- */const it=v,rt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:l,middlewareData:c}=e,u=
- // For type backwards-compatibility, the `OffsetOptions` type was also
- // Derivable.
- await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=a(n),c=f(n),u="y"===h(n),d=["left","top"].includes(l)?-1:1,m=r&&u?-1:1,p=s(e,t);
- // eslint-disable-next-line prefer-const
- let{mainAxis:g,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 c&&"number"==typeof w&&(y="end"===c?-1*w:w),u?{x:y*m,y:g*d}:{x:g*d,y:y*m}}
- /**
- * Modifies the placement by translating the floating element along the
- * specified axes.
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
- * object may be passed.
- * @see https://floating-ui.com/docs/offset
- */(e,t);
- // If the placement is the same and the arrow caused an alignment offset
- // then we don't need to change the positioning coordinates.
- return l===(null==(n=c.offset)?void 0:n.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:i+u.x,y:r+u.y,data:{...u,placement:l}}}}},lt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:l=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...d}=s(t,e),m={x:n,y:o},p=await v(e,d),g=h(a(i)),y=u(g);let w=m[y],x=m[g];if(r){const t="y"===y?"bottom":"right";w=c(w+p["y"===y?"top":"left"],w,w-p[t])}if(l){const t="y"===g?"bottom":"right";x=c(x+p["y"===g?"top":"left"],x,x-p[t])}const b=f.fn({...e,[y]:w,[g]:x});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[y]:r,[g]:l}}}}}},ct=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:u,elements:y}=e,{mainAxis:w=!0,crossAxis:x=!0,fallbackPlacements:b,fallbackStrategy:R="bestFit",fallbackAxisSideDirection:T="none",flipAlignment:L=!0,...E}=s(t,e);
- // If a reset by the arrow was caused due to an alignment offset being
- // added, we should skip any logic now since `flip()` has already done its
- // work.
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
- if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const A=a(i),D=h(c),O=a(c)===c,S=await(null==u.isRTL?void 0:u.isRTL(y.floating)),C=b||(O||!L?[g(c)]:function(t){const e=g(t);return[p(t),e,p(e)]}(c)),P="none"!==T;!b&&P&&C.push(...function(t,e,n,o){const i=f(t);let r=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],l=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:l;default:return[]}}(a(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(p)))),r}(c,L,T,S));const F=[c,...C],k=await v(e,E),B=[];let H=(null==(o=r.flip)?void 0:o.overflows)||[];if(w&&B.push(k[A]),x){const t=function(t,e,n){void 0===n&&(n=!1);const o=f(t),i=m(t),r=d(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=g(l)),[l,g(l)]}(i,l,S);B.push(k[t[0]],k[t[1]])}
- // One or more sides is overflowing.
- if(H=[...H,{placement:i,overflows:B}],!B.every((t=>t<=0))){var W,V;const t=((null==(W=r.flip)?void 0:W.index)||0)+1,e=F[t];if(e)
- // Try next placement and re-run the lifecycle.
- return{data:{index:t,overflows:H},reset:{placement:e}};
- // First, find the candidates that fit on the mainAxis side of overflow,
- // then find the placement that fits the best on the main crossAxis side.
- let n=null==(V=H.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:V.placement;
- // Otherwise fallback.
- if(!n)switch(R){case"bestFit":{var M;const t=null==(M=H.filter((t=>{if(P){const e=h(t.placement);return e===D||
- // Create a bias to the `y` side axis due to horizontal
- // reading directions favoring greater width.
- "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{}}}},st=e=>({name:"arrow",options:e,async fn(n){const{x:o,y:i,placement:r,rects:l,platform:a,elements:u,middlewareData:h}=n,{element:p,padding:g=0}=s(e,n)||{};
- // Since `element` is required, we don't Partial<> the type.
- if(null==p)return{};const w=y(g),x={x:o,y:i},v=m(r),b=d(v),R=await a.getDimensions(p),T="y"===v,L=T?"top":"left",E=T?"bottom":"right",A=T?"clientHeight":"clientWidth",D=l.reference[b]+l.reference[v]-x[v]-l.floating[b],O=x[v]-l.reference[v],S=await(null==a.getOffsetParent?void 0:a.getOffsetParent(p));let C=S?S[A]:0;
- // DOM platform can return `window` as the `offsetParent`.
- C&&await(null==a.isElement?void 0:a.isElement(S))||(C=u.floating[A]||l.floating[b]);const P=D/2-O/2,F=C/2-R[b]/2-1,k=t(w[L],F),B=t(w[E],F),H=k,W=C-R[b]-B,V=C/2-R[b]/2+P,M=c(H,V,W),z=!h.arrow&&null!=f(r)&&V!==M&&l.reference[b]/2-(V<H?k:B)-R[b]/2<0,N=z?V<H?V-H:V-W:0;
- // If the padding is large enough that it causes the arrow to no longer be
- // centered, modify the padding so that it is centered.
- return{[v]:x[v]+N,data:{[v]:M,centerOffset:V-M-N,...z&&{alignmentOffset:N}},reset:z}}})
- /**
- * Optimizes the visibility of the floating element by flipping the `placement`
- * in order to keep it in view when the preferred placement(s) will overflow the
- * clipping boundary. Alternative to `autoPlacement`.
- * @see https://floating-ui.com/docs/flip
- */,at=(t,e,n)=>{
- // This caches the expensive `getClippingElementAncestors` function so that
- // multiple lifecycle resets re-use the same result. It only lives for a
- // single call. If other functions become expensive, we can add them as well.
- const o=new Map,i={platform:et,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,c=r.filter(Boolean),s=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=x(a,o,s),d=o,h={},m=0;for(let p=0;p<c.length;p++){const{name:n,fn:r}=c[p],{x:g,y:y,data:w,reset:v}=await r({x:f,y:u,initialPlacement:o,placement:d,strategy:i,middlewareData:h,rects:a,platform:l,elements:{reference:t,floating:e}});f=null!=g?g:f,u=null!=y?y:u,h={...h,[n]:{...h[n],...w}},v&&m<=50&&(m++,"object"==typeof v&&(v.placement&&(d=v.placement),v.rects&&(a=!0===v.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):v.rects),({x:f,y:u}=x(a,d,s))),p=-1)}return{x:f,y:u,placement:d,strategy:i,middlewareData:h}})(t,e,{...i,platform:r})};
- /**
- * Modifies the placement by translating the floating element along the
- * specified axes.
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
- * object may be passed.
- * @see https://floating-ui.com/docs/offset
- */export{st as a,ot as b,at as c,it as d,ct as f,rt as o,lt as s};
- //# sourceMappingURL=@floating-ui-f285e0b8.js.map
|