site/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs
2024-10-14 08:09:33 +02:00

2 lines
8.9 KiB
JavaScript

import{rectToClientRect as t,detectOverflow as e,offset as n,autoPlacement as o,shift as i,flip as r,size as c,hide as l,arrow as s,inline as f,limitShift as u,computePosition as a}from"@floating-ui/core";const d=Math.min,h=Math.max,p=Math.round,m=Math.floor,g=t=>({x:t,y:t});function y(t){return x(t)?(t.nodeName||"").toLowerCase():"#document"}function w(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function v(t){var e;return null==(e=(x(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function x(t){return t instanceof Node||t instanceof w(t).Node}function b(t){return t instanceof Element||t instanceof w(t).Element}function L(t){return t instanceof HTMLElement||t instanceof w(t).HTMLElement}function T(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof w(t).ShadowRoot)}function R(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=O(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function E(t){return["table","td","th"].includes(y(t))}function S(t){const e=C(),n=O(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function C(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function F(t){return["html","body","#document"].includes(y(t))}function O(t){return w(t).getComputedStyle(t)}function D(t){return b(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function H(t){if("html"===y(t))return t;const e=t.assignedSlot||t.parentNode||T(t)&&t.host||v(t);return T(e)?e.host:e}function W(t){const e=H(t);return F(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&R(e)?e:W(e)}function M(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=W(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=w(i);return r?e.concat(c,c.visualViewport||[],R(i)?i:[],c.frameElement&&n?M(c.frameElement):[]):e.concat(i,M(i,[],n))}function z(t){const e=O(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=L(t),r=i?t.offsetWidth:n,c=i?t.offsetHeight:o,l=p(n)!==r||p(o)!==c;return l&&(n=r,o=c),{width:n,height:o,$:l}}function P(t){return b(t)?t:t.contextElement}function V(t){const e=P(t);if(!L(e))return g(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=z(e);let c=(r?p(n.width):n.width)/o,l=(r?p(n.height):n.height)/i;return c&&Number.isFinite(c)||(c=1),l&&Number.isFinite(l)||(l=1),{x:c,y:l}}const A=g(0);function N(t){const e=w(t);return C()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:A}function B(e,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=e.getBoundingClientRect(),c=P(e);let l=g(1);n&&(i?b(i)&&(l=V(i)):l=V(e));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==w(t))&&e}(c,o,i)?N(c):g(0);let f=(r.left+s.x)/l.x,u=(r.top+s.y)/l.y,a=r.width/l.x,d=r.height/l.y;if(c){const t=w(c),e=i&&b(i)?w(i):i;let n=t,o=n.frameElement;for(;o&&i&&e!==n;){const t=V(o),e=o.getBoundingClientRect(),i=O(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;f*=t.x,u*=t.y,a*=t.x,d*=t.y,f+=r,u+=c,n=w(o),o=n.frameElement}}return t({width:a,height:d,x:f,y:u})}const k=[":popover-open",":modal"];function I(t){return k.some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function q(t){return B(v(t)).left+D(t).scrollLeft}function X(e,n,o){let i;if("viewport"===n)i=function(t,e){const n=w(t),o=v(t),i=n.visualViewport;let r=o.clientWidth,c=o.clientHeight,l=0,s=0;if(i){r=i.width,c=i.height;const t=C();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:l,y:s}}(e,o);else if("document"===n)i=function(t){const e=v(t),n=D(t),o=t.ownerDocument.body,i=h(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=h(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+q(t);const l=-n.scrollTop;return"rtl"===O(o).direction&&(c+=h(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:c,y:l}}(v(e));else if(b(n))i=function(t,e){const n=B(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=L(t)?V(t):g(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(n,o);else{const t=N(e);i={...n,x:n.x-t.x,y:n.y-t.y}}return t(i)}function Y(t,e){const n=H(t);return!(n===e||!b(n)||F(n))&&("fixed"===O(n).position||Y(n,e))}function $(t,e,n){const o=L(e),i=v(e),r="fixed"===n,c=B(t,!0,r,e);let l={scrollLeft:0,scrollTop:0};const s=g(0);if(o||!o&&!r)if(("body"!==y(e)||R(i))&&(l=D(e)),o){const t=B(e,!0,r,e);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else i&&(s.x=q(i));return{x:c.left+l.scrollLeft-s.x,y:c.top+l.scrollTop-s.y,width:c.width,height:c.height}}function _(t){return"static"===O(t).position}function j(t,e){return L(t)&&"fixed"!==O(t).position?e?e(t):t.offsetParent:null}function G(t,e){const n=w(t);if(I(t))return n;if(!L(t)){let e=H(t);for(;e&&!F(e);){if(b(e)&&!_(e))return e;e=H(e)}return n}let o=j(t,e);for(;o&&E(o)&&_(o);)o=j(o,e);return o&&F(o)&&_(o)&&!S(o)?n:o||function(t){let e=H(t);for(;L(e)&&!F(e);){if(S(e))return e;e=H(e)}return null}(t)||n}const J={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,c=v(o),l=!!e&&I(e.floating);if(o===c||l&&r)return n;let s={scrollLeft:0,scrollTop:0},f=g(1);const u=g(0),a=L(o);if((a||!a&&!r)&&(("body"!==y(o)||R(c))&&(s=D(o)),L(o))){const t=B(o);f=V(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-s.scrollLeft*f.x+u.x,y:n.y*f.y-s.scrollTop*f.y+u.y}},getDocumentElement:v,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?I(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=M(t,[],!1).filter((t=>b(t)&&"body"!==y(t))),i=null;const r="fixed"===O(t).position;let c=r?H(t):t;for(;b(c)&&!F(c);){const e=O(c),n=S(c);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||R(c)&&!n&&Y(t,c))?o=o.filter((t=>t!==c)):i=e,c=H(c)}return e.set(t,o),o}(e,this._c):[].concat(n),o],c=r[0],l=r.reduce(((t,n)=>{const o=X(e,n,i);return t.top=h(o.top,t.top),t.right=d(o.right,t.right),t.bottom=d(o.bottom,t.bottom),t.left=h(o.left,t.left),t}),X(e,c,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:G,getElementRects:async function(t){const e=this.getOffsetParent||G,n=this.getDimensions,o=await n(t.floating);return{reference:$(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}=z(t);return{width:e,height:n}},getScale:V,isElement:b,isRTL:function(t){return"rtl"===O(t).direction}};function K(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:c="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,f=P(t),u=i||r?[...f?M(f):[],...M(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const a=f&&l?function(t,e){let n,o=null;const i=v(t);function r(){var t;clearTimeout(n),null==(t=o)||t.disconnect(),o=null}return function c(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),r();const{left:f,top:u,width:a,height:p}=t.getBoundingClientRect();if(l||e(),!a||!p)return;const g={rootMargin:-m(u)+"px "+-m(i.clientWidth-(f+a))+"px "+-m(i.clientHeight-(u+p))+"px "+-m(f)+"px",threshold:h(0,d(1,s))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==s){if(!y)return c();e?c(!1,e):n=setTimeout((()=>{c(!1,1e-7)}),1e3)}y=!1}try{o=new IntersectionObserver(w,{...g,root:i.ownerDocument})}catch(t){o=new IntersectionObserver(w,g)}o.observe(t)}(!0),r}(f,n):null;let p,g=-1,y=null;c&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame((()=>{var t;null==(t=y)||t.observe(e)}))),n()})),f&&!s&&y.observe(f),y.observe(e));let w=s?B(t):null;return s&&function e(){const o=B(t);!w||o.x===w.x&&o.y===w.y&&o.width===w.width&&o.height===w.height||n();w=o,p=requestAnimationFrame(e)}(),n(),()=>{var t;u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==a||a(),null==(t=y)||t.disconnect(),y=null,s&&cancelAnimationFrame(p)}}const Q=e,U=n,Z=o,tt=i,et=r,nt=c,ot=l,it=s,rt=f,ct=u,lt=(t,e,n)=>{const o=new Map,i={platform:J,...n},r={...i.platform,_c:o};return a(t,e,{...i,platform:r})};export{it as arrow,Z as autoPlacement,K as autoUpdate,lt as computePosition,Q as detectOverflow,et as flip,M as getOverflowAncestors,ot as hide,rt as inline,ct as limitShift,U as offset,J as platform,tt as shift,nt as size};