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.4.3 to 1.4.4

src/platform/convertOffsetParentRelativeRectToViewportRelativeRect.d.ts

167

dist/floating-ui.dom.esm.js

@@ -6,3 +6,3 @@ import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core';

var _node$ownerDocument;
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
}

@@ -30,5 +30,2 @@

}
function isElement(value) {
return value instanceof getWindow(value).Element;
}
function isShadowRoot(node) {

@@ -72,3 +69,3 @@ // Browsers without `ShadowRoot` support.

const floor = Math.floor;
const createEmptyCoords = v => ({
const createCoords = v => ({
x: v,

@@ -99,2 +96,6 @@ y: v

function isElement(value) {
return value instanceof getWindow(value).Element;
}
function unwrapElement(element) {

@@ -107,3 +108,3 @@ return !isElement(element) ? element.contextElement : element;

if (!isHTMLElement(domElement)) {
return createEmptyCoords(1);
return createCoords(1);
}

@@ -133,20 +134,22 @@ const rect = domElement.getBoundingClientRect();

const noOffsets = /*#__PURE__*/createEmptyCoords(0);
function getVisualOffsets(element, isFixed, floatingOffsetParent) {
var _win$visualViewport, _win$visualViewport2;
if (isFixed === void 0) {
isFixed = true;
}
if (!isSafari()) {
const noOffsets = /*#__PURE__*/createCoords(0);
function getVisualOffsets(element) {
const win = getWindow(element);
if (!isSafari() || !win.visualViewport) {
return noOffsets;
}
const win = element ? getWindow(element) : window;
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== win) {
return noOffsets;
}
return {
x: ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0,
y: ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0
x: win.visualViewport.offsetLeft,
y: win.visualViewport.offsetTop
};
}
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
if (isFixed === void 0) {
isFixed = false;
}
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
return false;
}
return isFixed;
}

@@ -162,3 +165,3 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {

const domElement = unwrapElement(element);
let scale = createEmptyCoords(1);
let scale = createCoords(1);
if (includeScale) {

@@ -173,3 +176,3 @@ if (offsetParent) {

}
const visualOffsets = getVisualOffsets(domElement, isFixedStrategy, offsetParent);
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
let x = (clientRect.left + visualOffsets.x) / scale.x;

@@ -206,6 +209,2 @@ let y = (clientRect.top + visualOffsets.y) / scale.y;

function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function getNodeScroll(element) {

@@ -224,2 +223,6 @@ if (isElement(element)) {

function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {

@@ -240,4 +243,4 @@ let {

};
let scale = createEmptyCoords(1);
const offsets = createEmptyCoords(0);
let scale = createCoords(1);
const offsets = createCoords(0);
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {

@@ -262,2 +265,6 @@ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {

function getClientRects(element) {
return Array.from(element.getClientRects());
}
function getWindowScrollBarX(element) {

@@ -361,3 +368,3 @@ // If <html> has a CSS width greater than the viewport, then this will be

const left = clientRect.left + element.clientLeft;
const scale = isHTMLElement(element) ? getScale(element) : createEmptyCoords(1);
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
const width = element.clientWidth * scale.x;

@@ -466,2 +473,32 @@ const height = element.clientHeight * scale.y;

function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const isFixed = strategy === 'fixed';
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = createCoords(0);
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
}
function getTrueOffsetParent(element, polyfill) {

@@ -505,59 +542,35 @@ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {

function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const isFixed = strategy === 'fixed';
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = createEmptyCoords(0);
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
scroll = getNodeScroll(offsetParent);
const getElementRects = async function (_ref) {
let {
reference,
floating,
strategy
} = _ref;
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
const getDimensionsFn = this.getDimensions;
return {
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
floating: {
x: 0,
y: 0,
...(await getDimensionsFn(floating))
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
};
function isRTL(element) {
return getComputedStyle(element).direction === 'rtl';
}
const platform = {
convertOffsetParentRelativeRectToViewportRelativeRect,
getDocumentElement,
getClippingRect,
convertOffsetParentRelativeRectToViewportRelativeRect,
isElement,
getOffsetParent,
getElementRects,
getClientRects,
getDimensions,
getOffsetParent,
getDocumentElement,
getScale,
async getElementRects(_ref) {
let {
reference,
floating,
strategy
} = _ref;
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
const getDimensionsFn = this.getDimensions;
return {
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
floating: {
x: 0,
y: 0,
...(await getDimensionsFn(floating))
}
};
},
getClientRects: element => Array.from(element.getClientRects()),
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
isElement,
isRTL
};

@@ -564,0 +577,0 @@

@@ -9,3 +9,3 @@ (function (global, factory) {

var _node$ownerDocument;
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
}

@@ -33,5 +33,2 @@

}
function isElement(value) {
return value instanceof getWindow(value).Element;
}
function isShadowRoot(node) {

@@ -75,3 +72,3 @@ // Browsers without `ShadowRoot` support.

const floor = Math.floor;
const createEmptyCoords = v => ({
const createCoords = v => ({
x: v,

@@ -102,2 +99,6 @@ y: v

function isElement(value) {
return value instanceof getWindow(value).Element;
}
function unwrapElement(element) {

@@ -110,3 +111,3 @@ return !isElement(element) ? element.contextElement : element;

if (!isHTMLElement(domElement)) {
return createEmptyCoords(1);
return createCoords(1);
}

@@ -136,20 +137,22 @@ const rect = domElement.getBoundingClientRect();

const noOffsets = /*#__PURE__*/createEmptyCoords(0);
function getVisualOffsets(element, isFixed, floatingOffsetParent) {
var _win$visualViewport, _win$visualViewport2;
if (isFixed === void 0) {
isFixed = true;
}
if (!isSafari()) {
const noOffsets = /*#__PURE__*/createCoords(0);
function getVisualOffsets(element) {
const win = getWindow(element);
if (!isSafari() || !win.visualViewport) {
return noOffsets;
}
const win = element ? getWindow(element) : window;
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== win) {
return noOffsets;
}
return {
x: ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0,
y: ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0
x: win.visualViewport.offsetLeft,
y: win.visualViewport.offsetTop
};
}
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
if (isFixed === void 0) {
isFixed = false;
}
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
return false;
}
return isFixed;
}

@@ -165,3 +168,3 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {

const domElement = unwrapElement(element);
let scale = createEmptyCoords(1);
let scale = createCoords(1);
if (includeScale) {

@@ -176,3 +179,3 @@ if (offsetParent) {

}
const visualOffsets = getVisualOffsets(domElement, isFixedStrategy, offsetParent);
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
let x = (clientRect.left + visualOffsets.x) / scale.x;

@@ -209,6 +212,2 @@ let y = (clientRect.top + visualOffsets.y) / scale.y;

function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function getNodeScroll(element) {

@@ -227,2 +226,6 @@ if (isElement(element)) {

function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {

@@ -243,4 +246,4 @@ let {

};
let scale = createEmptyCoords(1);
const offsets = createEmptyCoords(0);
let scale = createCoords(1);
const offsets = createCoords(0);
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {

@@ -265,2 +268,6 @@ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {

function getClientRects(element) {
return Array.from(element.getClientRects());
}
function getWindowScrollBarX(element) {

@@ -364,3 +371,3 @@ // If <html> has a CSS width greater than the viewport, then this will be

const left = clientRect.left + element.clientLeft;
const scale = isHTMLElement(element) ? getScale(element) : createEmptyCoords(1);
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
const width = element.clientWidth * scale.x;

@@ -469,2 +476,32 @@ const height = element.clientHeight * scale.y;

function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const isFixed = strategy === 'fixed';
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = createCoords(0);
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
}
function getTrueOffsetParent(element, polyfill) {

@@ -508,59 +545,35 @@ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {

function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const isFixed = strategy === 'fixed';
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = createEmptyCoords(0);
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
scroll = getNodeScroll(offsetParent);
const getElementRects = async function (_ref) {
let {
reference,
floating,
strategy
} = _ref;
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
const getDimensionsFn = this.getDimensions;
return {
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
floating: {
x: 0,
y: 0,
...(await getDimensionsFn(floating))
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
};
function isRTL(element) {
return getComputedStyle(element).direction === 'rtl';
}
const platform = {
convertOffsetParentRelativeRectToViewportRelativeRect,
getDocumentElement,
getClippingRect,
convertOffsetParentRelativeRectToViewportRelativeRect,
isElement,
getOffsetParent,
getElementRects,
getClientRects,
getDimensions,
getOffsetParent,
getDocumentElement,
getScale,
async getElementRects(_ref) {
let {
reference,
floating,
strategy
} = _ref;
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
const getDimensionsFn = this.getDimensions;
return {
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
floating: {
x: 0,
y: 0,
...(await getDimensionsFn(floating))
}
};
},
getClientRects: element => Array.from(element.getClientRects()),
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
isElement,
isRTL
};

@@ -788,4 +801,2 @@

Object.defineProperty(exports, '__esModule', { value: true });
}));

@@ -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 t instanceof n(t).Node}function r(t){return i(t)?(t.nodeName||"").toLowerCase():"#document"}function c(t){return t instanceof n(t).HTMLElement}function l(t){return t instanceof n(t).Element}function f(t){return"undefined"!=typeof ShadowRoot&&(t instanceof n(t).ShadowRoot||t instanceof ShadowRoot)}function s(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function u(t){return["table","td","th"].includes(r(t))}function d(t){const e=a(),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 a(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function h(t){return["html","body","#document"].includes(r(t))}const p=Math.min,m=Math.max,g=Math.round,y=Math.floor,w=t=>({x:t,y:t});function b(t){const e=o(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=c(t),l=r?t.offsetWidth:n,f=r?t.offsetHeight:i,s=g(n)!==l||g(i)!==f;return s&&(n=l,i=f),{width:n,height:i,$:s}}function x(t){return l(t)?t:t.contextElement}function v(t){const e=x(t);if(!c(e))return w(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=b(e);let l=(r?g(n.width):n.width)/o,f=(r?g(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),f&&Number.isFinite(f)||(f=1),{x:l,y:f}}const T=w(0);function O(t,e,o){var i,r;if(void 0===e&&(e=!0),!a())return T;const c=t?n(t):window;return!o||e&&o!==c?T:{x:(null==(i=c.visualViewport)?void 0:i.offsetLeft)||0,y:(null==(r=c.visualViewport)?void 0:r.offsetTop)||0}}function L(t,o,i,r){void 0===o&&(o=!1),void 0===i&&(i=!1);const c=t.getBoundingClientRect(),f=x(t);let s=w(1);o&&(r?l(r)&&(s=v(r)):s=v(t));const u=O(f,i,r);let d=(c.left+u.x)/s.x,a=(c.top+u.y)/s.y,h=c.width/s.x,p=c.height/s.y;if(f){const t=n(f),e=r&&l(r)?n(r):r;let o=t.frameElement;for(;o&&r&&e!==t;){const t=v(o),e=o.getBoundingClientRect(),i=getComputedStyle(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;d*=t.x,a*=t.y,h*=t.x,p*=t.y,d+=r,a+=c,o=n(o).frameElement}}return e.rectToClientRect({width:h,height:p,x:d,y:a})}function R(t){return((i(t)?t.ownerDocument:t.document)||window.document).documentElement}function P(t){return l(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function C(t){return L(R(t)).left+P(t).scrollLeft}function S(t){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||f(t)&&t.host||R(t);return f(e)?e.host:e}function E(t){const e=S(t);return h(e)?t.ownerDocument?t.ownerDocument.body:t.body:c(e)&&s(e)?e:E(e)}function F(t,e){var o;void 0===e&&(e=[]);const i=E(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=n(i);return r?e.concat(c,c.visualViewport||[],s(i)?i:[]):e.concat(i,F(i))}function j(t,i,r){let f;if("viewport"===i)f=function(t,e){const o=n(t),i=R(t),r=o.visualViewport;let c=i.clientWidth,l=i.clientHeight,f=0,s=0;if(r){c=r.width,l=r.height;const t=a();(!t||t&&"fixed"===e)&&(f=r.offsetLeft,s=r.offsetTop)}return{width:c,height:l,x:f,y:s}}(t,r);else if("document"===i)f=function(t){const e=R(t),n=P(t),i=t.ownerDocument.body,r=m(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=m(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+C(t);const f=-n.scrollTop;return"rtl"===o(i).direction&&(l+=m(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:f}}(R(t));else if(l(i))f=function(t,e){const n=L(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?v(t):w(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(i,r);else{const e=O(t);f={...i,x:i.x-e.x,y:i.y-e.y}}return e.rectToClientRect(f)}function D(t,e){const n=S(t);return!(n===e||!l(n)||h(n))&&("fixed"===o(n).position||D(n,e))}function W(t,e){return c(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function H(t,e){const i=n(t);if(!c(t))return i;let l=W(t,e);for(;l&&u(l)&&"static"===o(l).position;)l=W(l,e);return l&&("html"===r(l)||"body"===r(l)&&"static"===o(l).position&&!d(l))?i:l||function(t){let e=S(t);for(;c(e)&&!h(e);){if(d(e))return e;e=S(e)}return null}(t)||i}function M(t,e,n){const o=c(e),i=R(e),l="fixed"===n,f=L(t,!0,l,e);let u={scrollLeft:0,scrollTop:0};const d=w(0);if(o||!o&&!l)if(("body"!==r(e)||s(i))&&(u=P(e)),c(e)){const t=L(e,!0,l,e);d.x=t.x+e.clientLeft,d.y=t.y+e.clientTop}else i&&(d.x=C(i));return{x:f.left+u.scrollLeft-d.x,y:f.top+u.scrollTop-d.y,width:f.width,height:f.height}}const z={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:i,strategy:c}=t;const f="clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let i=F(t).filter((t=>l(t)&&"body"!==r(t))),c=null;const f="fixed"===o(t).position;let u=f?S(t):t;for(;l(u)&&!h(u);){const e=o(u),n=d(u);n||"fixed"!==e.position||(c=null),(f?!n&&!c:!n&&"static"===e.position&&c&&["absolute","fixed"].includes(c.position)||s(u)&&!n&&D(t,u))?i=i.filter((t=>t!==u)):c=e,u=S(u)}return e.set(t,i),i}(e,this._c):[].concat(n),u=[...f,i],a=u[0],g=u.reduce(((t,n)=>{const o=j(e,n,c);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}),j(e,a,c));return{width:g.right-g.left,height:g.bottom-g.top,x:g.left,y:g.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=c(n),l=R(n);if(n===l)return e;let f={scrollLeft:0,scrollTop:0},u=w(1);const d=w(0);if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||s(l))&&(f=P(n)),c(n))){const t=L(n);u=v(n),d.x=t.x+n.clientLeft,d.y=t.y+n.clientTop}return{width:e.width*u.x,height:e.height*u.y,x:e.x*u.x-f.scrollLeft*u.x+d.x,y:e.y*u.y-f.scrollTop*u.y+d.y}},isElement:l,getDimensions:function(t){return b(t)},getOffsetParent:H,getDocumentElement:R,getScale:v,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||H,r=this.getDimensions;return{reference:M(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:c="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,s=x(t),u=i||r?[...s?F(s):[],...F(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const d=s&&l?function(t,e){let n,o=null;const i=R(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null}return function c(l,f){void 0===l&&(l=!1),void 0===f&&(f=1),r();const{left:s,top:u,width:d,height:a}=t.getBoundingClientRect();if(l||e(),!d||!a)return;const h={rootMargin:-y(u)+"px "+-y(i.clientWidth-(s+d))+"px "+-y(i.clientHeight-(u+a))+"px "+-y(s)+"px",threshold:m(0,p(1,f))||1};let g=!0;function w(t){const e=t[0].intersectionRatio;if(e!==f){if(!g)return c();e?c(!1,e):n=setTimeout((()=>{c(!1,1e-7)}),100)}g=!1}try{o=new IntersectionObserver(w,{...h,root:i.ownerDocument})}catch(t){o=new IntersectionObserver(w,h)}o.observe(t)}(!0),r}(s,n):null;let a,h=-1,g=null;c&&(g=new ResizeObserver((t=>{let[o]=t;o&&o.target===s&&g&&(g.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{g&&g.observe(e)}))),n()})),s&&!f&&g.observe(s),g.observe(e));let w=f?L(t):null;return f&&function e(){const o=L(t);!w||o.x===w.x&&o.y===w.y&&o.width===w.width&&o.height===w.height||n();w=o,a=requestAnimationFrame(e)}(),n(),()=>{u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),d&&d(),g&&g.disconnect(),g=null,f&&cancelAnimationFrame(a)}},t.computePosition=(t,n,o)=>{const i=new Map,r={platform:z,...o},c={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:c})},t.getOverflowAncestors=F,t.platform=z,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==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i(t){return t instanceof n(t).Node}function r(t){return i(t)?(t.nodeName||"").toLowerCase():"#document"}function c(t){return t instanceof n(t).HTMLElement}function l(t){return"undefined"!=typeof ShadowRoot&&(t instanceof n(t).ShadowRoot||t instanceof ShadowRoot)}function f(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function s(t){return["table","td","th"].includes(r(t))}function u(t){const e=a(),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 a(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function d(t){return["html","body","#document"].includes(r(t))}const h=Math.min,p=Math.max,m=Math.round,g=Math.floor,y=t=>({x:t,y:t});function w(t){const e=o(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=c(t),l=r?t.offsetWidth:n,f=r?t.offsetHeight:i,s=m(n)!==l||m(i)!==f;return s&&(n=l,i=f),{width:n,height:i,$:s}}function b(t){return t instanceof n(t).Element}function x(t){return b(t)?t:t.contextElement}function v(t){const e=x(t);if(!c(e))return y(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=w(e);let l=(r?m(n.width):n.width)/o,f=(r?m(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),f&&Number.isFinite(f)||(f=1),{x:l,y:f}}const T=y(0);function O(t){const e=n(t);return a()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:T}function L(t,o,i,r){void 0===o&&(o=!1),void 0===i&&(i=!1);const c=t.getBoundingClientRect(),l=x(t);let f=y(1);o&&(r?b(r)&&(f=v(r)):f=v(t));const s=function(t,e,o){return void 0===e&&(e=!1),!(!o||e&&o!==n(t))&&e}(l,i,r)?O(l):y(0);let u=(c.left+s.x)/f.x,a=(c.top+s.y)/f.y,d=c.width/f.x,h=c.height/f.y;if(l){const t=n(l),e=r&&b(r)?n(r):r;let o=t.frameElement;for(;o&&r&&e!==t;){const t=v(o),e=o.getBoundingClientRect(),i=getComputedStyle(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;u*=t.x,a*=t.y,d*=t.x,h*=t.y,u+=r,a+=c,o=n(o).frameElement}}return e.rectToClientRect({width:d,height:h,x:u,y:a})}function R(t){return b(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function P(t){return((i(t)?t.ownerDocument:t.document)||window.document).documentElement}function C(t){return L(P(t)).left+R(t).scrollLeft}function S(t){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||l(t)&&t.host||P(t);return l(e)?e.host:e}function E(t){const e=S(t);return d(e)?t.ownerDocument?t.ownerDocument.body:t.body:c(e)&&f(e)?e:E(e)}function F(t,e){var o;void 0===e&&(e=[]);const i=E(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=n(i);return r?e.concat(c,c.visualViewport||[],f(i)?i:[]):e.concat(i,F(i))}function j(t,i,r){let l;if("viewport"===i)l=function(t,e){const o=n(t),i=P(t),r=o.visualViewport;let c=i.clientWidth,l=i.clientHeight,f=0,s=0;if(r){c=r.width,l=r.height;const t=a();(!t||t&&"fixed"===e)&&(f=r.offsetLeft,s=r.offsetTop)}return{width:c,height:l,x:f,y:s}}(t,r);else if("document"===i)l=function(t){const e=P(t),n=R(t),i=t.ownerDocument.body,r=p(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=p(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+C(t);const f=-n.scrollTop;return"rtl"===o(i).direction&&(l+=p(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:f}}(P(t));else if(b(i))l=function(t,e){const n=L(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?v(t):y(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(i,r);else{const e=O(t);l={...i,x:i.x-e.x,y:i.y-e.y}}return e.rectToClientRect(l)}function D(t,e){const n=S(t);return!(n===e||!b(n)||d(n))&&("fixed"===o(n).position||D(n,e))}function W(t,e,n){const o=c(e),i=P(e),l="fixed"===n,s=L(t,!0,l,e);let u={scrollLeft:0,scrollTop:0};const a=y(0);if(o||!o&&!l)if(("body"!==r(e)||f(i))&&(u=R(e)),c(e)){const t=L(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&(a.x=C(i));return{x:s.left+u.scrollLeft-a.x,y:s.top+u.scrollTop-a.y,width:s.width,height:s.height}}function H(t,e){return c(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function z(t,e){const i=n(t);if(!c(t))return i;let l=H(t,e);for(;l&&s(l)&&"static"===o(l).position;)l=H(l,e);return l&&("html"===r(l)||"body"===r(l)&&"static"===o(l).position&&!u(l))?i:l||function(t){let e=S(t);for(;c(e)&&!d(e);){if(u(e))return e;e=S(e)}return null}(t)||i}const M={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=c(n),l=P(n);if(n===l)return e;let s={scrollLeft:0,scrollTop:0},u=y(1);const a=y(0);if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||f(l))&&(s=R(n)),c(n))){const t=L(n);u=v(n),a.x=t.x+n.clientLeft,a.y=t.y+n.clientTop}return{width:e.width*u.x,height:e.height*u.y,x:e.x*u.x-s.scrollLeft*u.x+a.x,y:e.y*u.y-s.scrollTop*u.y+a.y}},getDocumentElement:P,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:i,strategy:c}=t;const l=[..."clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let i=F(t).filter((t=>b(t)&&"body"!==r(t))),c=null;const l="fixed"===o(t).position;let s=l?S(t):t;for(;b(s)&&!d(s);){const e=o(s),n=u(s);n||"fixed"!==e.position||(c=null),(l?!n&&!c:!n&&"static"===e.position&&c&&["absolute","fixed"].includes(c.position)||f(s)&&!n&&D(t,s))?i=i.filter((t=>t!==s)):c=e,s=S(s)}return e.set(t,i),i}(e,this._c):[].concat(n),i],s=l[0],a=l.reduce(((t,n)=>{const o=j(e,n,c);return t.top=p(o.top,t.top),t.right=h(o.right,t.right),t.bottom=h(o.bottom,t.bottom),t.left=p(o.left,t.left),t}),j(e,s,c));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:z,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||z,r=this.getDimensions;return{reference:W(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return w(t)},getScale:v,isElement:b,isRTL:function(t){return"rtl"===getComputedStyle(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:c="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,s=x(t),u=i||r?[...s?F(s):[],...F(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const a=s&&l?function(t,e){let n,o=null;const i=P(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null}return function c(l,f){void 0===l&&(l=!1),void 0===f&&(f=1),r();const{left:s,top:u,width:a,height:d}=t.getBoundingClientRect();if(l||e(),!a||!d)return;const m={rootMargin:-g(u)+"px "+-g(i.clientWidth-(s+a))+"px "+-g(i.clientHeight-(u+d))+"px "+-g(s)+"px",threshold:p(0,h(1,f))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==f){if(!y)return c();e?c(!1,e):n=setTimeout((()=>{c(!1,1e-7)}),100)}y=!1}try{o=new IntersectionObserver(w,{...m,root:i.ownerDocument})}catch(t){o=new IntersectionObserver(w,m)}o.observe(t)}(!0),r}(s,n):null;let d,m=-1,y=null;c&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===s&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e)}))),n()})),s&&!f&&y.observe(s),y.observe(e));let w=f?L(t):null;return f&&function e(){const o=L(t);!w||o.x===w.x&&o.y===w.y&&o.width===w.width&&o.height===w.height||n();w=o,d=requestAnimationFrame(e)}(),n(),()=>{u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),a&&a(),y&&y.disconnect(),y=null,f&&cancelAnimationFrame(d)}},t.computePosition=(t,n,o)=>{const i=new Map,r={platform:M,...o},c={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:c})},t.getOverflowAncestors=F,t.platform=M}));
{
"name": "@floating-ui/dom",
"version": "1.4.3",
"version": "1.4.4",
"@rollingversions": {

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

"scripts": {
"dev": "parcel test/visual/index.html",
"dev": "vite",
"build": "NODE_ENV=build rollup -c",
"test": "jest test/unit"
"test": "vitest"
},

@@ -67,7 +67,7 @@ "author": "atomiks",

"devDependencies": {
"@types/react": "^18.0.28",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.1.1"
"@types/react": "^18.2.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.0"
}
}

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

import { NodeScroll } from '../types';
import type { NodeScroll } from '../types';
export declare function getNodeScroll(element: Element | Window): NodeScroll;

@@ -1,4 +0,3 @@

export declare function getVisualOffsets(element: Element | undefined, isFixed?: boolean, floatingOffsetParent?: Element | Window | undefined): {
x: number;
y: number;
};
import type { Coords } from '@floating-ui/core';
export declare function getVisualOffsets(element: Element | undefined): Coords;
export declare function shouldAddVisualOffsets(element: Element | undefined, isFixed?: boolean, floatingOffsetParent?: Element | Window | undefined): boolean;

@@ -1,1 +0,1 @@

export declare function getWindow(node: Node): Window;
export declare function getWindow(node: Node | undefined): Window;

@@ -10,3 +10,2 @@ declare global {

export declare function isHTMLElement(value: any): value is HTMLElement;
export declare function isElement(value: any): value is Element;
export declare function isShadowRoot(node: Node): node is ShadowRoot;

@@ -13,0 +12,0 @@ export declare function isOverflowElement(element: Element): boolean;

@@ -5,5 +5,5 @@ export declare const min: (...values: number[]) => number;

export declare const floor: (x: number) => number;
export declare const createEmptyCoords: (v: number) => {
export declare const createCoords: (v: number) => {
x: number;
y: number;
};

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