Socket
Socket
Sign inDemoInstall

@floating-ui/dom

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/dom - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

src/utils/getScale.d.ts

73

dist/floating-ui.dom.esm.js
import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core';
export { arrow, autoPlacement, detectOverflow, flip, hide, inline, limitShift, offset, shift, size } from '@floating-ui/core';
const min = Math.min;
const max = Math.max;
const round = Math.round;
function getScale(element, paramRect) {
const rect = paramRect || element.getBoundingClientRect();
return {
x: element.offsetWidth > 0 ? round(rect.width) / element.offsetWidth || 1 : 1,
y: element.offsetHeight > 0 ? round(rect.height) / element.offsetHeight || 1 : 1
};
}
function getWindow(node) {

@@ -85,6 +97,2 @@ var _node$ownerDocument;

const min = Math.min;
const max = Math.max;
const round = Math.round;
function getBoundingClientRect(element, includeScale, isFixedStrategy) {

@@ -104,4 +112,6 @@ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;

let elementToCheckForScale = element;
let scaleX = 1;
let scaleY = 1;
let scale = {
x: 1,
y: 1
};

@@ -114,4 +124,3 @@ if (!isElement(element) && element.contextElement) {

if (includeScale && isHTMLElement(elementToCheckForScale)) {
scaleX = elementToCheckForScale.offsetWidth > 0 ? round(contextRect.width) / elementToCheckForScale.offsetWidth || 1 : 1;
scaleY = elementToCheckForScale.offsetHeight > 0 ? round(contextRect.height) / elementToCheckForScale.offsetHeight || 1 : 1;
scale = getScale(elementToCheckForScale, contextRect);
}

@@ -121,6 +130,6 @@

const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
const width = clientRect.width / scaleX;
const height = clientRect.height / scaleY;
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scale.x;
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scale.y;
const width = clientRect.width / scale.x;
const height = clientRect.height / scale.y;
return {

@@ -287,2 +296,6 @@ width,

};
let scale = {
x: 1,
y: 1
};
const offsets = {

@@ -300,2 +313,3 @@ x: 0,

const offsetRect = getBoundingClientRect(offsetParent);
scale = getScale(offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;

@@ -310,5 +324,7 @@ offsets.y = offsetRect.y + offsetParent.clientTop;

return { ...rect,
x: rect.x - scroll.scrollLeft + offsets.x,
y: rect.y - scroll.scrollTop + offsets.y
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
};

@@ -404,14 +420,22 @@ }

function getInnerBoundingClientRect(element, strategy) {
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
const top = clientRect.top + element.clientTop;
const left = clientRect.left + element.clientLeft;
const scale = isHTMLElement(element) ? getScale(element) : {
x: 1,
y: 1
};
const width = element.clientWidth * scale.x;
const height = element.clientHeight * scale.y;
const x = left * scale.x;
const y = top * scale.y;
return {
top,
left,
x: left,
y: top,
right: left + element.clientWidth,
bottom: top + element.clientHeight,
width: element.clientWidth,
height: element.clientHeight
top: y,
left: x,
right: x + width,
bottom: y + height,
x,
y,
width,
height
};

@@ -495,2 +519,3 @@ }

getDocumentElement,
getScale,

@@ -497,0 +522,0 @@ async getElementRects(_ref) {

@@ -7,2 +7,14 @@ (function (global, factory) {

const min = Math.min;
const max = Math.max;
const round = Math.round;
function getScale(element, paramRect) {
const rect = paramRect || element.getBoundingClientRect();
return {
x: element.offsetWidth > 0 ? round(rect.width) / element.offsetWidth || 1 : 1,
y: element.offsetHeight > 0 ? round(rect.height) / element.offsetHeight || 1 : 1
};
}
function getWindow(node) {

@@ -89,6 +101,2 @@ var _node$ownerDocument;

const min = Math.min;
const max = Math.max;
const round = Math.round;
function getBoundingClientRect(element, includeScale, isFixedStrategy) {

@@ -108,4 +116,6 @@ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;

let elementToCheckForScale = element;
let scaleX = 1;
let scaleY = 1;
let scale = {
x: 1,
y: 1
};

@@ -118,4 +128,3 @@ if (!isElement(element) && element.contextElement) {

if (includeScale && isHTMLElement(elementToCheckForScale)) {
scaleX = elementToCheckForScale.offsetWidth > 0 ? round(contextRect.width) / elementToCheckForScale.offsetWidth || 1 : 1;
scaleY = elementToCheckForScale.offsetHeight > 0 ? round(contextRect.height) / elementToCheckForScale.offsetHeight || 1 : 1;
scale = getScale(elementToCheckForScale, contextRect);
}

@@ -125,6 +134,6 @@

const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
const width = clientRect.width / scaleX;
const height = clientRect.height / scaleY;
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scale.x;
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scale.y;
const width = clientRect.width / scale.x;
const height = clientRect.height / scale.y;
return {

@@ -291,2 +300,6 @@ width,

};
let scale = {
x: 1,
y: 1
};
const offsets = {

@@ -304,2 +317,3 @@ x: 0,

const offsetRect = getBoundingClientRect(offsetParent);
scale = getScale(offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;

@@ -314,5 +328,7 @@ offsets.y = offsetRect.y + offsetParent.clientTop;

return { ...rect,
x: rect.x - scroll.scrollLeft + offsets.x,
y: rect.y - scroll.scrollTop + offsets.y
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
};

@@ -408,14 +424,22 @@ }

function getInnerBoundingClientRect(element, strategy) {
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
const top = clientRect.top + element.clientTop;
const left = clientRect.left + element.clientLeft;
const scale = isHTMLElement(element) ? getScale(element) : {
x: 1,
y: 1
};
const width = element.clientWidth * scale.x;
const height = element.clientHeight * scale.y;
const x = left * scale.x;
const y = top * scale.y;
return {
top,
left,
x: left,
y: top,
right: left + element.clientWidth,
bottom: top + element.clientHeight,
width: element.clientWidth,
height: element.clientHeight
top: y,
left: x,
right: x + width,
bottom: y + height,
x,
y,
width,
height
};

@@ -499,2 +523,3 @@ }

getDocumentElement,
getScale,

@@ -501,0 +526,0 @@ async getElementRects(_ref) {

@@ -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";function n(t){var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i(t){return f(t)?(t.nodeName||"").toLowerCase():""}function r(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map((t=>t.brand+"/"+t.version)).join(" "):navigator.userAgent}function l(t){return t instanceof n(t).HTMLElement}function c(t){return t instanceof n(t).Element}function f(t){return t instanceof n(t).Node}function s(t){if("undefined"==typeof ShadowRoot)return!1;return t instanceof n(t).ShadowRoot||t instanceof ShadowRoot}function u(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return/auto|scroll|overlay|hidden/.test(e+i+n)&&!["inline","contents"].includes(r)}function d(t){return["table","td","th"].includes(i(t))}function a(t){const e=/firefox/i.test(r()),n=o(t),i=n.backdropFilter||n.WebkitBackdropFilter;return"none"!==n.transform||"none"!==n.perspective||!!i&&"none"!==i||e&&"filter"===n.willChange||e&&!!n.filter&&"none"!==n.filter||["transform","perspective"].some((t=>n.willChange.includes(t)))||["paint","layout","strict","content"].some((t=>{const e=n.contain;return null!=e&&e.includes(t)}))}function h(){return!/^((?!chrome|android).)*safari/i.test(r())}function g(t){return["html","body","#document"].includes(i(t))}const p=Math.min,m=Math.max,y=Math.round;function w(t,e,o){var i,r,f,s;void 0===e&&(e=!1),void 0===o&&(o=!1);const u=t.getBoundingClientRect();let d=u,a=t,g=1,p=1;!c(t)&&t.contextElement&&(d=t.contextElement.getBoundingClientRect(),a=t.contextElement),e&&l(a)&&(g=a.offsetWidth>0&&y(d.width)/a.offsetWidth||1,p=a.offsetHeight>0&&y(d.height)/a.offsetHeight||1);const m=c(t)?n(t):window,w=!h()&&o,b=(u.left+(w&&null!=(i=null==(r=m.visualViewport)?void 0:r.offsetLeft)?i:0))/g,v=(u.top+(w&&null!=(f=null==(s=m.visualViewport)?void 0:s.offsetTop)?f:0))/p,x=u.width/g,L=u.height/p;return{width:x,height:L,top:v,right:b+x,bottom:v+L,left:b,x:b,y:v}}function b(t){return((f(t)?t.ownerDocument:t.document)||window.document).documentElement}function v(t){return c(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function x(t){return w(b(t)).left+v(t).scrollLeft}function L(t,e,n){const o=l(e),r=b(e),c=w(t,o&&function(t){const e=w(t);return y(e.width)!==t.offsetWidth||y(e.height)!==t.offsetHeight}(e),"fixed"===n);let f={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==i(e)||u(r))&&(f=v(e)),l(e)){const t=w(e,!0);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else r&&(s.x=x(r));return{x:c.left+f.scrollLeft-s.x,y:c.top+f.scrollTop-s.y,width:c.width,height:c.height}}function O(t){if("html"===i(t))return t;const e=t.assignedSlot||t.parentNode||(s(t)?t.host:null)||b(t);return s(e)?e.host:e}function P(t){return l(t)&&"fixed"!==o(t).position?t.offsetParent:null}function T(t){const e=n(t);let r=P(t);for(;r&&d(r)&&"static"===o(r).position;)r=P(r);return r&&("html"===i(r)||"body"===i(r)&&"static"===o(r).position&&!a(r))?e:r||function(t){let e=O(t);for(;l(e)&&!g(e);){if(a(e))return e;e=O(e)}return null}(t)||e}function E(t){const e=O(t);return g(e)?t.ownerDocument.body:l(e)&&u(e)?e:E(e)}function R(t,e){var o;void 0===e&&(e=[]);const i=E(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=n(i);return r?e.concat(l,l.visualViewport||[],u(i)?i:[]):e.concat(i,R(i))}function W(t,i,r){return"viewport"===i?e.rectToClientRect(function(t,e){const o=n(t),i=b(t),r=o.visualViewport;let l=i.clientWidth,c=i.clientHeight,f=0,s=0;if(r){l=r.width,c=r.height;const t=h();(t||!t&&"fixed"===e)&&(f=r.offsetLeft,s=r.offsetTop)}return{width:l,height:c,x:f,y:s}}(t,r)):c(i)?function(t,e){const n=w(t,!1,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft;return{top:o,left:i,x:i,y:o,right:i+t.clientWidth,bottom:o+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}(i,r):e.rectToClientRect(function(t){var e;const n=b(t),i=v(t),r=null==(e=t.ownerDocument)?void 0:e.body,l=m(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),c=m(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let f=-i.scrollLeft+x(t);const s=-i.scrollTop;return"rtl"===o(r||n).direction&&(f+=m(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:c,x:f,y:s}}(b(t)))}const j={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:r,strategy:l}=t;const f="clippingAncestors"===n?function(t){let e=R(t).filter((t=>c(t)&&"body"!==i(t))),n=null;const r="fixed"===o(t).position;let l=r?O(t):t;for(;c(l)&&!g(l);){const t=o(l),i=a(l);(r?i||n:i||"static"!==t.position||!n||!["absolute","fixed"].includes(n.position))?n=t:e=e.filter((t=>t!==l)),l=O(l)}return e}(e):[].concat(n),s=[...f,r],u=s[0],d=s.reduce(((t,n)=>{const o=W(e,n,l);return t.top=m(o.top,t.top),t.right=p(o.right,t.right),t.bottom=p(o.bottom,t.bottom),t.left=m(o.left,t.left),t}),W(e,u,l));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const r=l(n),c=b(n);if(n===c)return e;let f={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if((r||!r&&"fixed"!==o)&&(("body"!==i(n)||u(c))&&(f=v(n)),l(n))){const t=w(n);s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}return{...e,x:e.x-f.scrollLeft+s.x,y:e.y-f.scrollTop+s.y}},isElement:c,getDimensions:function(t){if(l(t))return{width:t.offsetWidth,height:t.offsetHeight};const e=w(t);return{width:e.width,height:e.height}},getOffsetParent:T,getDocumentElement:b,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||T,r=this.getDimensions;return{reference:L(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===o(t).direction};Object.defineProperty(t,"arrow",{enumerable:!0,get:function(){return e.arrow}}),Object.defineProperty(t,"autoPlacement",{enumerable:!0,get:function(){return e.autoPlacement}}),Object.defineProperty(t,"detectOverflow",{enumerable:!0,get:function(){return e.detectOverflow}}),Object.defineProperty(t,"flip",{enumerable:!0,get:function(){return e.flip}}),Object.defineProperty(t,"hide",{enumerable:!0,get:function(){return e.hide}}),Object.defineProperty(t,"inline",{enumerable:!0,get:function(){return e.inline}}),Object.defineProperty(t,"limitShift",{enumerable:!0,get:function(){return e.limitShift}}),Object.defineProperty(t,"offset",{enumerable:!0,get:function(){return e.offset}}),Object.defineProperty(t,"shift",{enumerable:!0,get:function(){return e.shift}}),Object.defineProperty(t,"size",{enumerable:!0,get:function(){return e.size}}),t.autoUpdate=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l=!0,animationFrame:f=!1}=o,s=i&&!f,u=s||r?[...c(t)?R(t):t.contextElement?R(t.contextElement):[],...R(e)]:[];u.forEach((t=>{s&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));let d,a=null;if(l){let o=!0;a=new ResizeObserver((()=>{o||n(),o=!1})),c(t)&&!f&&a.observe(t),c(t)||!t.contextElement||f||a.observe(t.contextElement),a.observe(e)}let h=f?w(t):null;return f&&function e(){const o=w(t);!h||o.x===h.x&&o.y===h.y&&o.width===h.width&&o.height===h.height||n();h=o,d=requestAnimationFrame(e)}(),n(),()=>{var t;u.forEach((t=>{s&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==(t=a)||t.disconnect(),a=null,f&&cancelAnimationFrame(d)}},t.computePosition=(t,n,o)=>e.computePosition(t,n,{platform:j,...o}),t.getOverflowAncestors=R,t.platform=j,Object.defineProperty(t,"__esModule",{value:!0})}));
!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;function r(t,e){const n=e||t.getBoundingClientRect();return{x:t.offsetWidth>0&&i(n.width)/t.offsetWidth||1,y:t.offsetHeight>0&&i(n.height)/t.offsetHeight||1}}function l(t){var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function c(t){return l(t).getComputedStyle(t)}function f(t){return a(t)?(t.nodeName||"").toLowerCase():""}function s(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map((t=>t.brand+"/"+t.version)).join(" "):navigator.userAgent}function u(t){return t instanceof l(t).HTMLElement}function d(t){return t instanceof l(t).Element}function a(t){return t instanceof l(t).Node}function h(t){if("undefined"==typeof ShadowRoot)return!1;return t instanceof l(t).ShadowRoot||t instanceof ShadowRoot}function g(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=c(t);return/auto|scroll|overlay|hidden/.test(e+o+n)&&!["inline","contents"].includes(i)}function p(t){return["table","td","th"].includes(f(t))}function m(t){const e=/firefox/i.test(s()),n=c(t),o=n.backdropFilter||n.WebkitBackdropFilter;return"none"!==n.transform||"none"!==n.perspective||!!o&&"none"!==o||e&&"filter"===n.willChange||e&&!!n.filter&&"none"!==n.filter||["transform","perspective"].some((t=>n.willChange.includes(t)))||["paint","layout","strict","content"].some((t=>{const e=n.contain;return null!=e&&e.includes(t)}))}function y(){return!/^((?!chrome|android).)*safari/i.test(s())}function w(t){return["html","body","#document"].includes(f(t))}function x(t,e,n){var o,i,c,f;void 0===e&&(e=!1),void 0===n&&(n=!1);const s=t.getBoundingClientRect();let a=s,h=t,g={x:1,y:1};!d(t)&&t.contextElement&&(a=t.contextElement.getBoundingClientRect(),h=t.contextElement),e&&u(h)&&(g=r(h,a));const p=d(t)?l(t):window,m=!y()&&n,w=(s.left+(m&&null!=(o=null==(i=p.visualViewport)?void 0:i.offsetLeft)?o:0))/g.x,x=(s.top+(m&&null!=(c=null==(f=p.visualViewport)?void 0:f.offsetTop)?c:0))/g.y,b=s.width/g.x,v=s.height/g.y;return{width:b,height:v,top:x,right:w+b,bottom:x+v,left:w,x:w,y:x}}function b(t){return((a(t)?t.ownerDocument:t.document)||window.document).documentElement}function v(t){return d(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function L(t){return x(b(t)).left+v(t).scrollLeft}function O(t,e,n){const o=u(e),r=b(e),l=x(t,o&&function(t){const e=x(t);return i(e.width)!==t.offsetWidth||i(e.height)!==t.offsetHeight}(e),"fixed"===n);let c={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==f(e)||g(r))&&(c=v(e)),u(e)){const t=x(e,!0);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else r&&(s.x=L(r));return{x:l.left+c.scrollLeft-s.x,y:l.top+c.scrollTop-s.y,width:l.width,height:l.height}}function P(t){if("html"===f(t))return t;const e=t.assignedSlot||t.parentNode||(h(t)?t.host:null)||b(t);return h(e)?e.host:e}function R(t){return u(t)&&"fixed"!==c(t).position?t.offsetParent:null}function T(t){const e=l(t);let n=R(t);for(;n&&p(n)&&"static"===c(n).position;)n=R(n);return n&&("html"===f(n)||"body"===f(n)&&"static"===c(n).position&&!m(n))?e:n||function(t){let e=P(t);for(;u(e)&&!w(e);){if(m(e))return e;e=P(e)}return null}(t)||e}function E(t){const e=P(t);return w(e)?t.ownerDocument.body:u(e)&&g(e)?e:E(e)}function j(t,e){var n;void 0===e&&(e=[]);const o=E(t),i=o===(null==(n=t.ownerDocument)?void 0:n.body),r=l(o);return i?e.concat(r,r.visualViewport||[],g(o)?o:[]):e.concat(o,j(o))}function C(t,n,i){return"viewport"===n?e.rectToClientRect(function(t,e){const n=l(t),o=b(t),i=n.visualViewport;let r=o.clientWidth,c=o.clientHeight,f=0,s=0;if(i){r=i.width,c=i.height;const t=y();(t||!t&&"fixed"===e)&&(f=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:f,y:s}}(t,i)):d(n)?function(t,e){const n=x(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,l=u(t)?r(t):{x:1,y:1},c=t.clientWidth*l.x,f=t.clientHeight*l.y,s=i*l.x,d=o*l.y;return{top:d,left:s,right:s+c,bottom:d+f,x:s,y:d,width:c,height:f}}(n,i):e.rectToClientRect(function(t){var e;const n=b(t),i=v(t),r=null==(e=t.ownerDocument)?void 0:e.body,l=o(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),f=o(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let s=-i.scrollLeft+L(t);const u=-i.scrollTop;return"rtl"===c(r||n).direction&&(s+=o(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:f,x:s,y:u}}(b(t)))}const W={getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:r,strategy:l}=t;const s="clippingAncestors"===i?function(t){let e=j(t).filter((t=>d(t)&&"body"!==f(t))),n=null;const o="fixed"===c(t).position;let i=o?P(t):t;for(;d(i)&&!w(i);){const t=c(i),r=m(i);(o?r||n:r||"static"!==t.position||!n||!["absolute","fixed"].includes(n.position))?n=t:e=e.filter((t=>t!==i)),i=P(i)}return e}(e):[].concat(i),u=[...s,r],a=u[0],h=u.reduce(((t,i)=>{const r=C(e,i,l);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}),C(e,a,l));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=u(n),l=b(n);if(n===l)return e;let c={scrollLeft:0,scrollTop:0},s={x:1,y:1};const d={x:0,y:0};if((i||!i&&"fixed"!==o)&&(("body"!==f(n)||g(l))&&(c=v(n)),u(n))){const t=x(n);s=r(n),d.x=t.x+n.clientLeft,d.y=t.y+n.clientTop}return{width:e.width*s.x,height:e.height*s.y,x:e.x*s.x-c.scrollLeft*s.x+d.x,y:e.y*s.y-c.scrollTop*s.y+d.y}},isElement:d,getDimensions:function(t){if(u(t))return{width:t.offsetWidth,height:t.offsetHeight};const e=x(t);return{width:e.width,height:e.height}},getOffsetParent:T,getDocumentElement:b,getScale:r,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||T,r=this.getDimensions;return{reference:O(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===c(t).direction};Object.defineProperty(t,"arrow",{enumerable:!0,get:function(){return e.arrow}}),Object.defineProperty(t,"autoPlacement",{enumerable:!0,get:function(){return e.autoPlacement}}),Object.defineProperty(t,"detectOverflow",{enumerable:!0,get:function(){return e.detectOverflow}}),Object.defineProperty(t,"flip",{enumerable:!0,get:function(){return e.flip}}),Object.defineProperty(t,"hide",{enumerable:!0,get:function(){return e.hide}}),Object.defineProperty(t,"inline",{enumerable:!0,get:function(){return e.inline}}),Object.defineProperty(t,"limitShift",{enumerable:!0,get:function(){return e.limitShift}}),Object.defineProperty(t,"offset",{enumerable:!0,get:function(){return e.offset}}),Object.defineProperty(t,"shift",{enumerable:!0,get:function(){return e.shift}}),Object.defineProperty(t,"size",{enumerable:!0,get:function(){return e.size}}),t.autoUpdate=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l=!0,animationFrame:c=!1}=o,f=i&&!c,s=f||r?[...d(t)?j(t):t.contextElement?j(t.contextElement):[],...j(e)]:[];s.forEach((t=>{f&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));let u,a=null;if(l){let o=!0;a=new ResizeObserver((()=>{o||n(),o=!1})),d(t)&&!c&&a.observe(t),d(t)||!t.contextElement||c||a.observe(t.contextElement),a.observe(e)}let h=c?x(t):null;return c&&function e(){const o=x(t);!h||o.x===h.x&&o.y===h.y&&o.width===h.width&&o.height===h.height||n();h=o,u=requestAnimationFrame(e)}(),n(),()=>{var t;s.forEach((t=>{f&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==(t=a)||t.disconnect(),a=null,c&&cancelAnimationFrame(u)}},t.computePosition=(t,n,o)=>e.computePosition(t,n,{platform:W,...o}),t.getOverflowAncestors=j,t.platform=W,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@floating-ui/dom",
"version": "1.0.8",
"version": "1.0.9",
"@rollingversions": {

@@ -64,3 +64,3 @@ "baseVersion": [

"dependencies": {
"@floating-ui/core": "^1.0.3"
"@floating-ui/core": "^1.0.4"
},

@@ -67,0 +67,0 @@ "devDependencies": {

@@ -26,2 +26,6 @@ import type { AutoPlacementOptions, ClientRectObject, DetectOverflowOptions as CoreDetectOverflowOptions, Dimensions, ElementRects, FlipOptions, HideOptions, Middleware as CoreMiddleware, MiddlewareArguments as CoreMiddlewareArguments, MiddlewareReturn, Padding, Rect, RootBoundary, ShiftOptions, SideObject, SizeOptions as CoreSizeOptions, Strategy, ComputePositionConfig as CoreComputePositionConfig } from '@floating-ui/core';

isRTL?: (element: Element) => Promisable<boolean>;
getScale?: (element: HTMLElement) => Promisable<{
x: number;
y: number;
}>;
}

@@ -28,0 +32,0 @@ export interface NodeScroll {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc