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.9 to 1.0.10

125

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) {

@@ -30,7 +18,13 @@ var _node$ownerDocument;

let uaString;
function getUAString() {
if (uaString) {
return uaString;
}
const uaData = navigator.userAgentData;
if (uaData && Array.isArray(uaData.brands)) {
return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
return uaString;
}

@@ -98,3 +92,33 @@

function getBoundingClientRect(element, includeScale, isFixedStrategy) {
const FALLBACK_SCALE = {
x: 1,
y: 1
};
function getScale(element) {
const domElement = !isElement(element) && element.contextElement ? element.contextElement : isElement(element) ? element : null;
if (!domElement) {
return FALLBACK_SCALE;
}
const rect = domElement.getBoundingClientRect();
const css = getComputedStyle(domElement);
let x = rect.width / parseFloat(css.width);
let y = rect.height / parseFloat(css.height); // 0, NaN, or Infinity should always fallback to 1.
if (!x || !Number.isFinite(x)) {
x = 1;
}
if (!y || !Number.isFinite(y)) {
y = 1;
}
return {
x,
y
};
}
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;

@@ -111,18 +135,14 @@

const clientRect = element.getBoundingClientRect();
let contextRect = clientRect;
let elementToCheckForScale = element;
let scale = {
x: 1,
y: 1
};
let scale = FALLBACK_SCALE;
if (!isElement(element) && element.contextElement) {
contextRect = element.contextElement.getBoundingClientRect();
elementToCheckForScale = element.contextElement;
if (includeScale) {
if (offsetParent) {
if (isElement(offsetParent)) {
scale = getScale(offsetParent);
}
} else {
scale = getScale(element);
}
}
if (includeScale && isHTMLElement(elementToCheckForScale)) {
scale = getScale(elementToCheckForScale, contextRect);
}
const win = isElement(element) ? getWindow(element) : window;

@@ -170,12 +190,6 @@ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;

function isScaled(element) {
const rect = getBoundingClientRect(element);
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
}
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
let scroll = {

@@ -315,3 +329,3 @@ scrollLeft: 0,

offsets.y = offsetRect.y + offsetParent.clientTop;
} // This doesn't appear to be need to be negated.
} // This doesn't appear to need to be negated.
// else if (documentElement) {

@@ -359,2 +373,5 @@ // offsets.x = getWindowScrollBarX(documentElement);

const min = Math.min;
const max = Math.max;
// of the `<html>` and `<body>` rect bounds if horizontally scrollable

@@ -418,2 +435,3 @@

// Returns the inner client rect, subtracting scrollbars if present
function getInnerBoundingClientRect(element, strategy) {

@@ -453,8 +471,14 @@ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');

return rectToClientRect(getDocumentRect(getDocumentElement(element)));
} // A "clipping ancestor" is an overflowable container with the characteristic of
// clipping (or hiding) overflowing elements with a position different from
// `initial`
} // 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 getClippingElementAncestors(element) {
function getClippingElementAncestors(element, cache) {
const cachedResult = cache.get(element);
if (cachedResult) {
return cachedResult;
}
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');

@@ -481,2 +505,3 @@ let currentContainingBlockComputedStyle = null;

cache.set(element, result);
return result;

@@ -494,3 +519,3 @@ } // Gets the maximum area that the element is visible in due to any number of

} = _ref;
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element) : [].concat(boundary);
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
const clippingAncestors = [...elementClippingAncestors, rootBoundary];

@@ -629,7 +654,19 @@ const firstClippingAncestor = clippingAncestors[0];

const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
platform,
...options
});
const computePosition = (reference, floating, options) => {
// 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 cache = new Map();
const mergedOptions = {
platform,
...options
};
const platformWithCache = { ...mergedOptions.platform,
_c: cache
};
return computePosition$1(reference, floating, { ...mergedOptions,
platform: platformWithCache
});
};
export { autoUpdate, computePosition, getOverflowAncestors, platform };

@@ -7,14 +7,2 @@ (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) {

@@ -34,7 +22,13 @@ var _node$ownerDocument;

let uaString;
function getUAString() {
if (uaString) {
return uaString;
}
const uaData = navigator.userAgentData;
if (uaData && Array.isArray(uaData.brands)) {
return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
return uaString;
}

@@ -102,3 +96,33 @@

function getBoundingClientRect(element, includeScale, isFixedStrategy) {
const FALLBACK_SCALE = {
x: 1,
y: 1
};
function getScale(element) {
const domElement = !isElement(element) && element.contextElement ? element.contextElement : isElement(element) ? element : null;
if (!domElement) {
return FALLBACK_SCALE;
}
const rect = domElement.getBoundingClientRect();
const css = getComputedStyle(domElement);
let x = rect.width / parseFloat(css.width);
let y = rect.height / parseFloat(css.height); // 0, NaN, or Infinity should always fallback to 1.
if (!x || !Number.isFinite(x)) {
x = 1;
}
if (!y || !Number.isFinite(y)) {
y = 1;
}
return {
x,
y
};
}
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;

@@ -115,18 +139,14 @@

const clientRect = element.getBoundingClientRect();
let contextRect = clientRect;
let elementToCheckForScale = element;
let scale = {
x: 1,
y: 1
};
let scale = FALLBACK_SCALE;
if (!isElement(element) && element.contextElement) {
contextRect = element.contextElement.getBoundingClientRect();
elementToCheckForScale = element.contextElement;
if (includeScale) {
if (offsetParent) {
if (isElement(offsetParent)) {
scale = getScale(offsetParent);
}
} else {
scale = getScale(element);
}
}
if (includeScale && isHTMLElement(elementToCheckForScale)) {
scale = getScale(elementToCheckForScale, contextRect);
}
const win = isElement(element) ? getWindow(element) : window;

@@ -174,12 +194,6 @@ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;

function isScaled(element) {
const rect = getBoundingClientRect(element);
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
}
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
let scroll = {

@@ -319,3 +333,3 @@ scrollLeft: 0,

offsets.y = offsetRect.y + offsetParent.clientTop;
} // This doesn't appear to be need to be negated.
} // This doesn't appear to need to be negated.
// else if (documentElement) {

@@ -363,2 +377,5 @@ // offsets.x = getWindowScrollBarX(documentElement);

const min = Math.min;
const max = Math.max;
// of the `<html>` and `<body>` rect bounds if horizontally scrollable

@@ -422,2 +439,3 @@

// Returns the inner client rect, subtracting scrollbars if present
function getInnerBoundingClientRect(element, strategy) {

@@ -457,8 +475,14 @@ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');

return core.rectToClientRect(getDocumentRect(getDocumentElement(element)));
} // A "clipping ancestor" is an overflowable container with the characteristic of
// clipping (or hiding) overflowing elements with a position different from
// `initial`
} // 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 getClippingElementAncestors(element) {
function getClippingElementAncestors(element, cache) {
const cachedResult = cache.get(element);
if (cachedResult) {
return cachedResult;
}
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');

@@ -485,2 +509,3 @@ let currentContainingBlockComputedStyle = null;

cache.set(element, result);
return result;

@@ -498,3 +523,3 @@ } // Gets the maximum area that the element is visible in due to any number of

} = _ref;
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element) : [].concat(boundary);
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
const clippingAncestors = [...elementClippingAncestors, rootBoundary];

@@ -633,6 +658,18 @@ const firstClippingAncestor = clippingAncestors[0];

const computePosition = (reference, floating, options) => core.computePosition(reference, floating, {
platform,
...options
});
const computePosition = (reference, floating, options) => {
// 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 cache = new Map();
const mergedOptions = {
platform,
...options
};
const platformWithCache = { ...mergedOptions.platform,
_c: cache
};
return core.computePosition(reference, floating, { ...mergedOptions,
platform: platformWithCache
});
};

@@ -639,0 +676,0 @@ Object.defineProperty(exports, 'arrow', {

@@ -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;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})}));
!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 s(t)?(t.nodeName||"").toLowerCase():""}let r;function l(){if(r)return r;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(r=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),r):navigator.userAgent}function c(t){return t instanceof n(t).HTMLElement}function f(t){return t instanceof n(t).Element}function s(t){return t instanceof n(t).Node}function u(t){if("undefined"==typeof ShadowRoot)return!1;return t instanceof n(t).ShadowRoot||t instanceof ShadowRoot}function a(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 h(t){const e=/firefox/i.test(l()),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 p(){return!/^((?!chrome|android).)*safari/i.test(l())}function g(t){return["html","body","#document"].includes(i(t))}const m={x:1,y:1};function y(t){const e=!f(t)&&t.contextElement?t.contextElement:f(t)?t:null;if(!e)return m;const n=e.getBoundingClientRect(),i=o(e);let r=n.width/parseFloat(i.width),l=n.height/parseFloat(i.height);return r&&Number.isFinite(r)||(r=1),l&&Number.isFinite(l)||(l=1),{x:r,y:l}}function w(t,e,o,i){var r,l,c,s;void 0===e&&(e=!1),void 0===o&&(o=!1);const u=t.getBoundingClientRect();let a=m;e&&(i?f(i)&&(a=y(i)):a=y(t));const d=f(t)?n(t):window,h=!p()&&o,g=(u.left+(h&&null!=(r=null==(l=d.visualViewport)?void 0:l.offsetLeft)?r:0))/a.x,w=(u.top+(h&&null!=(c=null==(s=d.visualViewport)?void 0:s.offsetTop)?c:0))/a.y,b=u.width/a.x,x=u.height/a.y;return{width:b,height:x,top:w,right:g+b,bottom:w+x,left:g,x:g,y:w}}function b(t){return((s(t)?t.ownerDocument:t.document)||window.document).documentElement}function x(t){return f(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function v(t){return w(b(t)).left+x(t).scrollLeft}function L(t,e,n){const o=c(e),r=b(e),l=w(t,!0,"fixed"===n,e);let f={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==i(e)||a(r))&&(f=x(e)),c(e)){const t=w(e,!0);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else r&&(s.x=v(r));return{x:l.left+f.scrollLeft-s.x,y:l.top+f.scrollTop-s.y,width:l.width,height:l.height}}function O(t){if("html"===i(t))return t;const e=t.assignedSlot||t.parentNode||(u(t)?t.host:null)||b(t);return u(e)?e.host:e}function P(t){return c(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&&!h(r))?e:r||function(t){let e=O(t);for(;c(e)&&!g(e);){if(h(e))return e;e=O(e)}return null}(t)||e}const R=Math.min,E=Math.max;function j(t){const e=O(t);return g(e)?t.ownerDocument.body:c(e)&&a(e)?e:j(e)}function C(t,e){var o;void 0===e&&(e=[]);const i=j(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=n(i);return r?e.concat(l,l.visualViewport||[],a(i)?i:[]):e.concat(i,C(i))}function F(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=p();(t||!t&&"fixed"===e)&&(f=r.offsetLeft,s=r.offsetTop)}return{width:l,height:c,x:f,y:s}}(t,r)):f(i)?function(t,e){const n=w(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?y(t):{x:1,y:1},l=t.clientWidth*r.x,f=t.clientHeight*r.y,s=i*r.x,u=o*r.y;return{top:u,left:s,right:s+l,bottom:u+f,x:s,y:u,width:l,height:f}}(i,r):e.rectToClientRect(function(t){var e;const n=b(t),i=x(t),r=null==(e=t.ownerDocument)?void 0:e.body,l=E(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),c=E(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let f=-i.scrollLeft+v(t);const s=-i.scrollTop;return"rtl"===o(r||n).direction&&(f+=E(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:c,x:f,y:s}}(b(t)))}const D={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:r,strategy:l}=t;const c="clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let r=C(t).filter((t=>f(t)&&"body"!==i(t))),l=null;const c="fixed"===o(t).position;let s=c?O(t):t;for(;f(s)&&!g(s);){const t=o(s),e=h(s);(c?e||l:e||"static"!==t.position||!l||!["absolute","fixed"].includes(l.position))?l=t:r=r.filter((t=>t!==s)),s=O(s)}return e.set(t,r),r}(e,this._c):[].concat(n),s=[...c,r],u=s[0],a=s.reduce(((t,n)=>{const o=F(e,n,l);return t.top=E(o.top,t.top),t.right=R(o.right,t.right),t.bottom=R(o.bottom,t.bottom),t.left=E(o.left,t.left),t}),F(e,u,l));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const r=c(n),l=b(n);if(n===l)return e;let f={scrollLeft:0,scrollTop:0},s={x:1,y:1};const u={x:0,y:0};if((r||!r&&"fixed"!==o)&&(("body"!==i(n)||a(l))&&(f=x(n)),c(n))){const t=w(n);s=y(n),u.x=t.x+n.clientLeft,u.y=t.y+n.clientTop}return{width:e.width*s.x,height:e.height*s.y,x:e.x*s.x-f.scrollLeft*s.x+u.x,y:e.y*s.y-f.scrollTop*s.y+u.y}},isElement:f,getDimensions:function(t){if(c(t))return{width:t.offsetWidth,height:t.offsetHeight};const e=w(t);return{width:e.width,height:e.height}},getOffsetParent:T,getDocumentElement:b,getScale:y,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:c=!1}=o,s=i&&!c,u=s||r?[...f(t)?C(t):t.contextElement?C(t.contextElement):[],...C(e)]:[];u.forEach((t=>{s&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));let a,d=null;if(l){let o=!0;d=new ResizeObserver((()=>{o||n(),o=!1})),f(t)&&!c&&d.observe(t),f(t)||!t.contextElement||c||d.observe(t.contextElement),d.observe(e)}let h=c?w(t):null;return c&&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,a=requestAnimationFrame(e)}(),n(),()=>{var t;u.forEach((t=>{s&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==(t=d)||t.disconnect(),d=null,c&&cancelAnimationFrame(a)}},t.computePosition=(t,n,o)=>{const i=new Map,r={platform:D,...o},l={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:l})},t.getOverflowAncestors=C,t.platform=D,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "@floating-ui/dom",
"version": "1.0.9",
"version": "1.0.10",
"@rollingversions": {

@@ -5,0 +5,0 @@ "baseVersion": [

import type { ClientRectObject, VirtualElement } from '@floating-ui/core';
export declare function getBoundingClientRect(element: Element | VirtualElement, includeScale?: boolean, isFixedStrategy?: boolean): ClientRectObject;
export declare function getBoundingClientRect(element: Element | VirtualElement, includeScale?: boolean, isFixedStrategy?: boolean, offsetParent?: Element | Window): ClientRectObject;
import { Boundary, RootBoundary, Rect, Strategy } from '@floating-ui/core';
export declare function getClippingRect({ element, boundary, rootBoundary, strategy, }: {
import { Platform, ReferenceElement } from '../types';
declare type PlatformWithCache = Platform & {
_c: Map<ReferenceElement, Element[]>;
};
export declare function getClippingRect(this: PlatformWithCache, { element, boundary, rootBoundary, strategy, }: {
element: Element;

@@ -8,1 +12,2 @@ boundary: Boundary;

}): Rect;
export {};

@@ -1,2 +0,7 @@

import type { Coords, Rect } from '@floating-ui/core';
export declare function getScale(element: HTMLElement, paramRect?: Rect): Coords;
import type { Coords } from '@floating-ui/core';
import type { VirtualElement } from '../types';
export declare const FALLBACK_SCALE: {
x: number;
y: number;
};
export declare function getScale(element: Element | VirtualElement): Coords;

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