@floating-ui/dom
Advanced tools
Comparing version 1.6.11 to 1.6.12
import { rectToClientRect, detectOverflow as detectOverflow$1, offset as offset$1, autoPlacement as autoPlacement$1, shift as shift$1, flip as flip$1, size as size$1, hide as hide$1, arrow as arrow$1, inline as inline$1, limitShift as limitShift$1, computePosition as computePosition$1 } from '@floating-ui/core'; | ||
import { round, createCoords, max, min, floor } from '@floating-ui/utils'; | ||
import { getComputedStyle, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getNodeScroll, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom'; | ||
import { getComputedStyle, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom'; | ||
export { getOverflowAncestors } from '@floating-ui/utils/dom'; | ||
@@ -133,2 +133,27 @@ | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
function getWindowScrollBarX(element, rect) { | ||
const leftScroll = getNodeScroll(element).scrollLeft; | ||
if (!rect) { | ||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; | ||
} | ||
return rect.left + leftScroll; | ||
} | ||
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) { | ||
if (ignoreScrollbarX === void 0) { | ||
ignoreScrollbarX = false; | ||
} | ||
const htmlRect = documentElement.getBoundingClientRect(); | ||
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : | ||
// RTL <body> scrollbar. | ||
getWindowScrollBarX(documentElement, htmlRect)); | ||
const y = htmlRect.top + scroll.scrollTop; | ||
return { | ||
x, | ||
y | ||
}; | ||
} | ||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { | ||
@@ -165,7 +190,8 @@ let { | ||
} | ||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0); | ||
return { | ||
width: rect.width * scale.x, | ||
height: rect.height * scale.y, | ||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x, | ||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y | ||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, | ||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y | ||
}; | ||
@@ -178,12 +204,2 @@ } | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
function getWindowScrollBarX(element, rect) { | ||
const leftScroll = getNodeScroll(element).scrollLeft; | ||
if (!rect) { | ||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; | ||
} | ||
return rect.left + leftScroll; | ||
} | ||
// Gets the entire size of the scrollable document area, even extending outside | ||
@@ -263,5 +279,6 @@ // of the `<html>` and `<body>` rect bounds if horizontally scrollable. | ||
rect = { | ||
...clippingAncestor, | ||
x: clippingAncestor.x - visualOffsets.x, | ||
y: clippingAncestor.y - visualOffsets.y | ||
y: clippingAncestor.y - visualOffsets.y, | ||
width: clippingAncestor.width, | ||
height: clippingAncestor.height | ||
}; | ||
@@ -376,13 +393,5 @@ } | ||
} | ||
let htmlX = 0; | ||
let htmlY = 0; | ||
if (documentElement && !isOffsetParentAnElement && !isFixed) { | ||
const htmlRect = documentElement.getBoundingClientRect(); | ||
htmlY = htmlRect.top + scroll.scrollTop; | ||
htmlX = htmlRect.left + scroll.scrollLeft - | ||
// RTL <body> scrollbar. | ||
getWindowScrollBarX(documentElement, htmlRect); | ||
} | ||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlX; | ||
const y = rect.top + scroll.scrollTop - offsets.y - htmlY; | ||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); | ||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; | ||
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; | ||
return { | ||
@@ -389,0 +398,0 @@ x, |
@@ -300,2 +300,27 @@ (function (global, factory) { | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
function getWindowScrollBarX(element, rect) { | ||
const leftScroll = getNodeScroll(element).scrollLeft; | ||
if (!rect) { | ||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; | ||
} | ||
return rect.left + leftScroll; | ||
} | ||
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) { | ||
if (ignoreScrollbarX === void 0) { | ||
ignoreScrollbarX = false; | ||
} | ||
const htmlRect = documentElement.getBoundingClientRect(); | ||
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : | ||
// RTL <body> scrollbar. | ||
getWindowScrollBarX(documentElement, htmlRect)); | ||
const y = htmlRect.top + scroll.scrollTop; | ||
return { | ||
x, | ||
y | ||
}; | ||
} | ||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { | ||
@@ -332,7 +357,8 @@ let { | ||
} | ||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0); | ||
return { | ||
width: rect.width * scale.x, | ||
height: rect.height * scale.y, | ||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x, | ||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y | ||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x, | ||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y | ||
}; | ||
@@ -345,12 +371,2 @@ } | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
function getWindowScrollBarX(element, rect) { | ||
const leftScroll = getNodeScroll(element).scrollLeft; | ||
if (!rect) { | ||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll; | ||
} | ||
return rect.left + leftScroll; | ||
} | ||
// Gets the entire size of the scrollable document area, even extending outside | ||
@@ -430,5 +446,6 @@ // of the `<html>` and `<body>` rect bounds if horizontally scrollable. | ||
rect = { | ||
...clippingAncestor, | ||
x: clippingAncestor.x - visualOffsets.x, | ||
y: clippingAncestor.y - visualOffsets.y | ||
y: clippingAncestor.y - visualOffsets.y, | ||
width: clippingAncestor.width, | ||
height: clippingAncestor.height | ||
}; | ||
@@ -543,13 +560,5 @@ } | ||
} | ||
let htmlX = 0; | ||
let htmlY = 0; | ||
if (documentElement && !isOffsetParentAnElement && !isFixed) { | ||
const htmlRect = documentElement.getBoundingClientRect(); | ||
htmlY = htmlRect.top + scroll.scrollTop; | ||
htmlX = htmlRect.left + scroll.scrollLeft - | ||
// RTL <body> scrollbar. | ||
getWindowScrollBarX(documentElement, htmlRect); | ||
} | ||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlX; | ||
const y = rect.top + scroll.scrollTop - offsets.y - htmlY; | ||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0); | ||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x; | ||
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y; | ||
return { | ||
@@ -556,0 +565,0 @@ x, |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@floating-ui/core")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM={},t.FloatingUICore)}(this,(function(t,e){"use strict";const n=Math.min,o=Math.max,i=Math.round,r=Math.floor,c=t=>({x:t,y:t});function l(){return"undefined"!=typeof window}function s(t){return a(t)?(t.nodeName||"").toLowerCase():"#document"}function f(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function u(t){var e;return null==(e=(a(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function a(t){return!!l()&&(t instanceof Node||t instanceof f(t).Node)}function d(t){return!!l()&&(t instanceof Element||t instanceof f(t).Element)}function h(t){return!!l()&&(t instanceof HTMLElement||t instanceof f(t).HTMLElement)}function p(t){return!(!l()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof f(t).ShadowRoot)}function g(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=b(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function m(t){return["table","td","th"].includes(s(t))}function y(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function w(t){const e=v(),n=d(t)?b(t):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 v(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function x(t){return["html","body","#document"].includes(s(t))}function b(t){return f(t).getComputedStyle(t)}function T(t){return d(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function L(t){if("html"===s(t))return t;const e=t.assignedSlot||t.parentNode||p(t)&&t.host||u(t);return p(e)?e.host:e}function R(t){const e=L(t);return x(e)?t.ownerDocument?t.ownerDocument.body:t.body:h(e)&&g(e)?e:R(e)}function C(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=R(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=f(i);if(r){const t=E(c);return e.concat(c,c.visualViewport||[],g(i)?i:[],t&&n?C(t):[])}return e.concat(i,C(i,[],n))}function E(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function S(t){const e=b(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=h(t),c=r?t.offsetWidth:n,l=r?t.offsetHeight:o,s=i(n)!==c||i(o)!==l;return s&&(n=c,o=l),{width:n,height:o,$:s}}function F(t){return d(t)?t:t.contextElement}function O(t){const e=F(t);if(!h(e))return c(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:l}=S(e);let s=(l?i(n.width):n.width)/o,f=(l?i(n.height):n.height)/r;return s&&Number.isFinite(s)||(s=1),f&&Number.isFinite(f)||(f=1),{x:s,y:f}}const D=c(0);function H(t){const e=f(t);return v()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:D}function P(t,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=t.getBoundingClientRect(),l=F(t);let s=c(1);n&&(i?d(i)&&(s=O(i)):s=O(t));const u=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==f(t))&&e}(l,o,i)?H(l):c(0);let a=(r.left+u.x)/s.x,h=(r.top+u.y)/s.y,p=r.width/s.x,g=r.height/s.y;if(l){const t=f(l),e=i&&d(i)?f(i):i;let n=t,o=E(n);for(;o&&i&&e!==n;){const t=O(o),e=o.getBoundingClientRect(),i=b(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;a*=t.x,h*=t.y,p*=t.x,g*=t.y,a+=r,h+=c,n=f(o),o=E(n)}}return e.rectToClientRect({width:p,height:g,x:a,y:h})}function W(t,e){const n=T(t).scrollLeft;return e?e.left+n:P(u(t)).left+n}function M(t,n,i){let r;if("viewport"===n)r=function(t,e){const n=f(t),o=u(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=v();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:l,y:s}}(t,i);else if("document"===n)r=function(t){const e=u(t),n=T(t),i=t.ownerDocument.body,r=o(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=o(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+W(t);const s=-n.scrollTop;return"rtl"===b(i).direction&&(l+=o(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:s}}(u(t));else if(d(n))r=function(t,e){const n=P(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=h(t)?O(t):c(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(n,i);else{const e=H(t);r={...n,x:n.x-e.x,y:n.y-e.y}}return e.rectToClientRect(r)}function z(t,e){const n=L(t);return!(n===e||!d(n)||x(n))&&("fixed"===b(n).position||z(n,e))}function A(t,e,n){const o=h(e),i=u(e),r="fixed"===n,l=P(t,!0,r,e);let f={scrollLeft:0,scrollTop:0};const a=c(0);if(o||!o&&!r)if(("body"!==s(e)||g(i))&&(f=T(e)),o){const t=P(e,!0,r,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&(a.x=W(i));let d=0,p=0;if(i&&!o&&!r){const t=i.getBoundingClientRect();p=t.top+f.scrollTop,d=t.left+f.scrollLeft-W(i,t)}return{x:l.left+f.scrollLeft-a.x-d,y:l.top+f.scrollTop-a.y-p,width:l.width,height:l.height}}function V(t){return"static"===b(t).position}function B(t,e){if(!h(t)||"fixed"===b(t).position)return null;if(e)return e(t);let n=t.offsetParent;return u(t)===n&&(n=n.ownerDocument.body),n}function N(t,e){const n=f(t);if(y(t))return n;if(!h(t)){let e=L(t);for(;e&&!x(e);){if(d(e)&&!V(e))return e;e=L(e)}return n}let o=B(t,e);for(;o&&m(o)&&V(o);)o=B(o,e);return o&&x(o)&&V(o)&&!w(o)?n:o||function(t){let e=L(t);for(;h(e)&&!x(e);){if(w(e))return e;if(y(e))return null;e=L(e)}return null}(t)||n}const I={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,l=u(o),f=!!e&&y(e.floating);if(o===l||f&&r)return n;let a={scrollLeft:0,scrollTop:0},d=c(1);const p=c(0),m=h(o);if((m||!m&&!r)&&(("body"!==s(o)||g(l))&&(a=T(o)),h(o))){const t=P(o);d=O(o),p.x=t.x+o.clientLeft,p.y=t.y+o.clientTop}return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-a.scrollLeft*d.x+p.x,y:n.y*d.y-a.scrollTop*d.y+p.y}},getDocumentElement:u,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:r,strategy:c}=t;const l=[..."clippingAncestors"===i?y(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=C(t,[],!1).filter((t=>d(t)&&"body"!==s(t))),i=null;const r="fixed"===b(t).position;let c=r?L(t):t;for(;d(c)&&!x(c);){const e=b(c),n=w(c);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||g(c)&&!n&&z(t,c))?o=o.filter((t=>t!==c)):i=e,c=L(c)}return e.set(t,o),o}(e,this._c):[].concat(i),r],f=l[0],u=l.reduce(((t,i)=>{const r=M(e,i,c);return t.top=o(r.top,t.top),t.right=n(r.right,t.right),t.bottom=n(r.bottom,t.bottom),t.left=o(r.left,t.left),t}),M(e,f,c));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:N,getElementRects:async function(t){const e=this.getOffsetParent||N,n=this.getDimensions,o=await n(t.floating);return{reference:A(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}=S(t);return{width:e,height:n}},getScale:O,isElement:d,isRTL:function(t){return"rtl"===b(t).direction}};const k=e.detectOverflow,q=e.offset,U=e.autoPlacement,j=e.shift,X=e.flip,Y=e.size,$=e.hide,_=e.arrow,G=e.inline,J=e.limitShift;t.arrow=_,t.autoPlacement=U,t.autoUpdate=function(t,e,i,c){void 0===c&&(c={});const{ancestorScroll:l=!0,ancestorResize:s=!0,elementResize:f="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:d=!1}=c,h=F(t),p=l||s?[...h?C(h):[],...C(e)]:[];p.forEach((t=>{l&&t.addEventListener("scroll",i,{passive:!0}),s&&t.addEventListener("resize",i)}));const g=h&&a?function(t,e){let i,c=null;const l=u(t);function s(){var t;clearTimeout(i),null==(t=c)||t.disconnect(),c=null}return function f(u,a){void 0===u&&(u=!1),void 0===a&&(a=1),s();const{left:d,top:h,width:p,height:g}=t.getBoundingClientRect();if(u||e(),!p||!g)return;const m={rootMargin:-r(h)+"px "+-r(l.clientWidth-(d+p))+"px "+-r(l.clientHeight-(h+g))+"px "+-r(d)+"px",threshold:o(0,n(1,a))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==a){if(!y)return f();e?f(!1,e):i=setTimeout((()=>{f(!1,1e-7)}),1e3)}y=!1}try{c=new IntersectionObserver(w,{...m,root:l.ownerDocument})}catch(t){c=new IntersectionObserver(w,m)}c.observe(t)}(!0),s}(h,i):null;let m,y=-1,w=null;f&&(w=new ResizeObserver((t=>{let[n]=t;n&&n.target===h&&w&&(w.unobserve(e),cancelAnimationFrame(y),y=requestAnimationFrame((()=>{var t;null==(t=w)||t.observe(e)}))),i()})),h&&!d&&w.observe(h),w.observe(e));let v=d?P(t):null;return d&&function e(){const n=P(t);!v||n.x===v.x&&n.y===v.y&&n.width===v.width&&n.height===v.height||i();v=n,m=requestAnimationFrame(e)}(),i(),()=>{var t;p.forEach((t=>{l&&t.removeEventListener("scroll",i),s&&t.removeEventListener("resize",i)})),null==g||g(),null==(t=w)||t.disconnect(),w=null,d&&cancelAnimationFrame(m)}},t.computePosition=(t,n,o)=>{const i=new Map,r={platform:I,...o},c={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:c})},t.detectOverflow=k,t.flip=X,t.getOverflowAncestors=C,t.hide=$,t.inline=G,t.limitShift=J,t.offset=q,t.platform=I,t.shift=j,t.size=Y})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@floating-ui/core")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM={},t.FloatingUICore)}(this,(function(t,e){"use strict";const n=Math.min,o=Math.max,i=Math.round,r=Math.floor,c=t=>({x:t,y:t});function l(){return"undefined"!=typeof window}function s(t){return d(t)?(t.nodeName||"").toLowerCase():"#document"}function f(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function u(t){var e;return null==(e=(d(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function d(t){return!!l()&&(t instanceof Node||t instanceof f(t).Node)}function a(t){return!!l()&&(t instanceof Element||t instanceof f(t).Element)}function h(t){return!!l()&&(t instanceof HTMLElement||t instanceof f(t).HTMLElement)}function p(t){return!(!l()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof f(t).ShadowRoot)}function g(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=b(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function m(t){return["table","td","th"].includes(s(t))}function y(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function w(t){const e=x(),n=a(t)?b(t):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 x(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function v(t){return["html","body","#document"].includes(s(t))}function b(t){return f(t).getComputedStyle(t)}function T(t){return a(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function L(t){if("html"===s(t))return t;const e=t.assignedSlot||t.parentNode||p(t)&&t.host||u(t);return p(e)?e.host:e}function R(t){const e=L(t);return v(e)?t.ownerDocument?t.ownerDocument.body:t.body:h(e)&&g(e)?e:R(e)}function C(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=R(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=f(i);if(r){const t=E(c);return e.concat(c,c.visualViewport||[],g(i)?i:[],t&&n?C(t):[])}return e.concat(i,C(i,[],n))}function E(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function S(t){const e=b(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=h(t),c=r?t.offsetWidth:n,l=r?t.offsetHeight:o,s=i(n)!==c||i(o)!==l;return s&&(n=c,o=l),{width:n,height:o,$:s}}function F(t){return a(t)?t:t.contextElement}function O(t){const e=F(t);if(!h(e))return c(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:l}=S(e);let s=(l?i(n.width):n.width)/o,f=(l?i(n.height):n.height)/r;return s&&Number.isFinite(s)||(s=1),f&&Number.isFinite(f)||(f=1),{x:s,y:f}}const D=c(0);function H(t){const e=f(t);return x()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:D}function P(t,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=t.getBoundingClientRect(),l=F(t);let s=c(1);n&&(i?a(i)&&(s=O(i)):s=O(t));const u=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==f(t))&&e}(l,o,i)?H(l):c(0);let d=(r.left+u.x)/s.x,h=(r.top+u.y)/s.y,p=r.width/s.x,g=r.height/s.y;if(l){const t=f(l),e=i&&a(i)?f(i):i;let n=t,o=E(n);for(;o&&i&&e!==n;){const t=O(o),e=o.getBoundingClientRect(),i=b(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;d*=t.x,h*=t.y,p*=t.x,g*=t.y,d+=r,h+=c,n=f(o),o=E(n)}}return e.rectToClientRect({width:p,height:g,x:d,y:h})}function W(t,e){const n=T(t).scrollLeft;return e?e.left+n:P(u(t)).left+n}function M(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:W(t,o)),y:o.top+e.scrollTop}}function z(t,n,i){let r;if("viewport"===n)r=function(t,e){const n=f(t),o=u(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=x();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:l,y:s}}(t,i);else if("document"===n)r=function(t){const e=u(t),n=T(t),i=t.ownerDocument.body,r=o(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=o(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+W(t);const s=-n.scrollTop;return"rtl"===b(i).direction&&(l+=o(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:s}}(u(t));else if(a(n))r=function(t,e){const n=P(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=h(t)?O(t):c(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(n,i);else{const e=H(t);r={x:n.x-e.x,y:n.y-e.y,width:n.width,height:n.height}}return e.rectToClientRect(r)}function A(t,e){const n=L(t);return!(n===e||!a(n)||v(n))&&("fixed"===b(n).position||A(n,e))}function V(t,e,n){const o=h(e),i=u(e),r="fixed"===n,l=P(t,!0,r,e);let f={scrollLeft:0,scrollTop:0};const d=c(0);if(o||!o&&!r)if(("body"!==s(e)||g(i))&&(f=T(e)),o){const t=P(e,!0,r,e);d.x=t.x+e.clientLeft,d.y=t.y+e.clientTop}else i&&(d.x=W(i));const a=!i||o||r?c(0):M(i,f);return{x:l.left+f.scrollLeft-d.x-a.x,y:l.top+f.scrollTop-d.y-a.y,width:l.width,height:l.height}}function B(t){return"static"===b(t).position}function N(t,e){if(!h(t)||"fixed"===b(t).position)return null;if(e)return e(t);let n=t.offsetParent;return u(t)===n&&(n=n.ownerDocument.body),n}function I(t,e){const n=f(t);if(y(t))return n;if(!h(t)){let e=L(t);for(;e&&!v(e);){if(a(e)&&!B(e))return e;e=L(e)}return n}let o=N(t,e);for(;o&&m(o)&&B(o);)o=N(o,e);return o&&v(o)&&B(o)&&!w(o)?n:o||function(t){let e=L(t);for(;h(e)&&!v(e);){if(w(e))return e;if(y(e))return null;e=L(e)}return null}(t)||n}const k={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,l=u(o),f=!!e&&y(e.floating);if(o===l||f&&r)return n;let d={scrollLeft:0,scrollTop:0},a=c(1);const p=c(0),m=h(o);if((m||!m&&!r)&&(("body"!==s(o)||g(l))&&(d=T(o)),h(o))){const t=P(o);a=O(o),p.x=t.x+o.clientLeft,p.y=t.y+o.clientTop}const w=!l||m||r?c(0):M(l,d,!0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-d.scrollLeft*a.x+p.x+w.x,y:n.y*a.y-d.scrollTop*a.y+p.y+w.y}},getDocumentElement:u,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:r,strategy:c}=t;const l=[..."clippingAncestors"===i?y(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=C(t,[],!1).filter((t=>a(t)&&"body"!==s(t))),i=null;const r="fixed"===b(t).position;let c=r?L(t):t;for(;a(c)&&!v(c);){const e=b(c),n=w(c);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||g(c)&&!n&&A(t,c))?o=o.filter((t=>t!==c)):i=e,c=L(c)}return e.set(t,o),o}(e,this._c):[].concat(i),r],f=l[0],u=l.reduce(((t,i)=>{const r=z(e,i,c);return t.top=o(r.top,t.top),t.right=n(r.right,t.right),t.bottom=n(r.bottom,t.bottom),t.left=o(r.left,t.left),t}),z(e,f,c));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:I,getElementRects:async function(t){const e=this.getOffsetParent||I,n=this.getDimensions,o=await n(t.floating);return{reference:V(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}=S(t);return{width:e,height:n}},getScale:O,isElement:a,isRTL:function(t){return"rtl"===b(t).direction}};const q=e.detectOverflow,U=e.offset,j=e.autoPlacement,X=e.shift,Y=e.flip,$=e.size,_=e.hide,G=e.arrow,J=e.inline,K=e.limitShift;t.arrow=G,t.autoPlacement=j,t.autoUpdate=function(t,e,i,c){void 0===c&&(c={});const{ancestorScroll:l=!0,ancestorResize:s=!0,elementResize:f="function"==typeof ResizeObserver,layoutShift:d="function"==typeof IntersectionObserver,animationFrame:a=!1}=c,h=F(t),p=l||s?[...h?C(h):[],...C(e)]:[];p.forEach((t=>{l&&t.addEventListener("scroll",i,{passive:!0}),s&&t.addEventListener("resize",i)}));const g=h&&d?function(t,e){let i,c=null;const l=u(t);function s(){var t;clearTimeout(i),null==(t=c)||t.disconnect(),c=null}return function f(u,d){void 0===u&&(u=!1),void 0===d&&(d=1),s();const{left:a,top:h,width:p,height:g}=t.getBoundingClientRect();if(u||e(),!p||!g)return;const m={rootMargin:-r(h)+"px "+-r(l.clientWidth-(a+p))+"px "+-r(l.clientHeight-(h+g))+"px "+-r(a)+"px",threshold:o(0,n(1,d))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==d){if(!y)return f();e?f(!1,e):i=setTimeout((()=>{f(!1,1e-7)}),1e3)}y=!1}try{c=new IntersectionObserver(w,{...m,root:l.ownerDocument})}catch(t){c=new IntersectionObserver(w,m)}c.observe(t)}(!0),s}(h,i):null;let m,y=-1,w=null;f&&(w=new ResizeObserver((t=>{let[n]=t;n&&n.target===h&&w&&(w.unobserve(e),cancelAnimationFrame(y),y=requestAnimationFrame((()=>{var t;null==(t=w)||t.observe(e)}))),i()})),h&&!a&&w.observe(h),w.observe(e));let x=a?P(t):null;return a&&function e(){const n=P(t);!x||n.x===x.x&&n.y===x.y&&n.width===x.width&&n.height===x.height||i();x=n,m=requestAnimationFrame(e)}(),i(),()=>{var t;p.forEach((t=>{l&&t.removeEventListener("scroll",i),s&&t.removeEventListener("resize",i)})),null==g||g(),null==(t=w)||t.disconnect(),w=null,a&&cancelAnimationFrame(m)}},t.computePosition=(t,n,o)=>{const i=new Map,r={platform:k,...o},c={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:c})},t.detectOverflow=q,t.flip=Y,t.getOverflowAncestors=C,t.hide=_,t.inline=J,t.limitShift=K,t.offset=U,t.platform=k,t.shift=X,t.size=$})); |
{ | ||
"name": "@floating-ui/dom", | ||
"version": "1.6.11", | ||
"version": "1.6.12", | ||
"description": "Floating UI for the web", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162365
3502