Initial commit

This commit is contained in:
Marek Lesko
2025-08-19 16:58:51 +02:00
commit a2f7e2285a
908 changed files with 160315 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import { isShadowRoot } from "./instanceOf.js";
export default function contains(parent, child) {
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
if (parent.contains(child)) {
return true;
} // then fallback to custom implementation with Shadow DOM support
else if (rootNode && isShadowRoot(rootNode)) {
var next = child;
do {
if (next && parent.isSameNode(next)) {
return true;
} // $FlowFixMe[prop-missing]: need a better way to handle this...
next = next.parentNode || next.host;
} while (next);
} // Give up, the result is false
return false;
}

View File

@@ -0,0 +1 @@
import{isShadowRoot}from"./instanceOf.js";export default function contains(o,t){var e=t.getRootNode&&t.getRootNode();if(o.contains(t))return!0;if(e&&isShadowRoot(e)){var i=t;do{if(i&&o.isSameNode(i))return!0}while(i=i.parentNode||i.host)}return!1}

View File

@@ -0,0 +1,41 @@
import { isElement, isHTMLElement } from "./instanceOf.js";
import { round } from "../utils/math.js";
import getWindow from "./getWindow.js";
import isLayoutViewport from "./isLayoutViewport.js";
export default function getBoundingClientRect(element, includeScale, isFixedStrategy) {
if (includeScale === void 0) {
includeScale = false;
}
if (isFixedStrategy === void 0) {
isFixedStrategy = false;
}
var clientRect = element.getBoundingClientRect();
var scaleX = 1;
var scaleY = 1;
if (includeScale && isHTMLElement(element)) {
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
}
var _ref = isElement(element) ? getWindow(element) : window,
visualViewport = _ref.visualViewport;
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
var width = clientRect.width / scaleX;
var height = clientRect.height / scaleY;
return {
width: width,
height: height,
top: y,
right: x + width,
bottom: y + height,
left: x,
x: x,
y: y
};
}

View File

@@ -0,0 +1 @@
import{isElement,isHTMLElement}from"./instanceOf.js";import{round}from"../utils/math.js";import getWindow from"./getWindow.js";import isLayoutViewport from"./isLayoutViewport.js";export default function getBoundingClientRect(t,i,e){void 0===i&&(i=!1),void 0===e&&(e=!1);var o=t.getBoundingClientRect(),f=1,n=1;i&&isHTMLElement(t)&&(f=0<t.offsetWidth&&round(o.width)/t.offsetWidth||1,n=0<t.offsetHeight&&round(o.height)/t.offsetHeight||1);i=(isElement(t)?getWindow(t):window).visualViewport,t=!isLayoutViewport()&&e,e=(o.left+(t&&i?i.offsetLeft:0))/f,t=(o.top+(t&&i?i.offsetTop:0))/n,i=o.width/f,f=o.height/n;return{width:i,height:f,top:t,right:e+i,bottom:t+f,left:e,x:e,y:t}}

View File

@@ -0,0 +1,70 @@
import { viewport } from "../enums.js";
import getViewportRect from "./getViewportRect.js";
import getDocumentRect from "./getDocumentRect.js";
import listScrollParents from "./listScrollParents.js";
import getOffsetParent from "./getOffsetParent.js";
import getDocumentElement from "./getDocumentElement.js";
import getComputedStyle from "./getComputedStyle.js";
import { isElement, isHTMLElement } from "./instanceOf.js";
import getBoundingClientRect from "./getBoundingClientRect.js";
import getParentNode from "./getParentNode.js";
import contains from "./contains.js";
import getNodeName from "./getNodeName.js";
import rectToClientRect from "../utils/rectToClientRect.js";
import { max, min } from "../utils/math.js";
function getInnerBoundingClientRect(element, strategy) {
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
rect.top = rect.top + element.clientTop;
rect.left = rect.left + element.clientLeft;
rect.bottom = rect.top + element.clientHeight;
rect.right = rect.left + element.clientWidth;
rect.width = element.clientWidth;
rect.height = element.clientHeight;
rect.x = rect.left;
rect.y = rect.top;
return rect;
}
function getClientRectFromMixedType(element, clippingParent, strategy) {
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
} // A "clipping parent" is an overflowable container with the characteristic of
// clipping (or hiding) overflowing elements with a position different from
// `initial`
function getClippingParents(element) {
var clippingParents = listScrollParents(getParentNode(element));
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
if (!isElement(clipperElement)) {
return [];
} // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
return clippingParents.filter(function (clippingParent) {
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
});
} // Gets the maximum area that the element is visible in due to any number of
// clipping parents
export default function getClippingRect(element, boundary, rootBoundary, strategy) {
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
var firstClippingParent = clippingParents[0];
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
accRect.top = max(rect.top, accRect.top);
accRect.right = min(rect.right, accRect.right);
accRect.bottom = min(rect.bottom, accRect.bottom);
accRect.left = max(rect.left, accRect.left);
return accRect;
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
clippingRect.width = clippingRect.right - clippingRect.left;
clippingRect.height = clippingRect.bottom - clippingRect.top;
clippingRect.x = clippingRect.left;
clippingRect.y = clippingRect.top;
return clippingRect;
}

View File

@@ -0,0 +1 @@
import{viewport}from"../enums.js";import getViewportRect from"./getViewportRect.js";import getDocumentRect from"./getDocumentRect.js";import listScrollParents from"./listScrollParents.js";import getOffsetParent from"./getOffsetParent.js";import getDocumentElement from"./getDocumentElement.js";import getComputedStyle from"./getComputedStyle.js";import{isElement,isHTMLElement}from"./instanceOf.js";import getBoundingClientRect from"./getBoundingClientRect.js";import getParentNode from"./getParentNode.js";import contains from"./contains.js";import getNodeName from"./getNodeName.js";import rectToClientRect from"../utils/rectToClientRect.js";import{max,min}from"../utils/math.js";function getInnerBoundingClientRect(t,e){e=getBoundingClientRect(t,!1,"fixed"===e);return e.top=e.top+t.clientTop,e.left=e.left+t.clientLeft,e.bottom=e.top+t.clientHeight,e.right=e.left+t.clientWidth,e.width=t.clientWidth,e.height=t.clientHeight,e.x=e.left,e.y=e.top,e}function getClientRectFromMixedType(t,e,o){return e===viewport?rectToClientRect(getViewportRect(t,o)):isElement(e)?getInnerBoundingClientRect(e,o):rectToClientRect(getDocumentRect(getDocumentElement(t)))}function getClippingParents(t){var e=listScrollParents(getParentNode(t)),o=0<=["absolute","fixed"].indexOf(getComputedStyle(t).position)&&isHTMLElement(t)?getOffsetParent(t):t;return isElement(o)?e.filter(function(t){return isElement(t)&&contains(t,o)&&"body"!==getNodeName(t)}):[]}export default function getClippingRect(o,t,e,n){t="clippingParents"===t?getClippingParents(o):[].concat(t),t=[].concat(t,[e]),e=t[0],t=t.reduce(function(t,e){e=getClientRectFromMixedType(o,e,n);return t.top=max(e.top,t.top),t.right=min(e.right,t.right),t.bottom=min(e.bottom,t.bottom),t.left=max(e.left,t.left),t},getClientRectFromMixedType(o,e,n));return t.width=t.right-t.left,t.height=t.bottom-t.top,t.x=t.left,t.y=t.top,t}

View File

@@ -0,0 +1,58 @@
import getBoundingClientRect from "./getBoundingClientRect.js";
import getNodeScroll from "./getNodeScroll.js";
import getNodeName from "./getNodeName.js";
import { isHTMLElement } from "./instanceOf.js";
import getWindowScrollBarX from "./getWindowScrollBarX.js";
import getDocumentElement from "./getDocumentElement.js";
import isScrollParent from "./isScrollParent.js";
import { round } from "../utils/math.js";
function isElementScaled(element) {
var rect = element.getBoundingClientRect();
var scaleX = round(rect.width) / element.offsetWidth || 1;
var scaleY = round(rect.height) / element.offsetHeight || 1;
return scaleX !== 1 || scaleY !== 1;
} // Returns the composite rect of an element relative to its offsetParent.
// Composite means it takes into account transforms as well as layout.
export default function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
if (isFixed === void 0) {
isFixed = false;
}
var isOffsetParentAnElement = isHTMLElement(offsetParent);
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
var documentElement = getDocumentElement(offsetParent);
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
var scroll = {
scrollLeft: 0,
scrollTop: 0
};
var offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
isScrollParent(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
offsets = getBoundingClientRect(offsetParent, true);
offsets.x += offsetParent.clientLeft;
offsets.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
};
}

View File

@@ -0,0 +1 @@
import getBoundingClientRect from"./getBoundingClientRect.js";import getNodeScroll from"./getNodeScroll.js";import getNodeName from"./getNodeName.js";import{isHTMLElement}from"./instanceOf.js";import getWindowScrollBarX from"./getWindowScrollBarX.js";import getDocumentElement from"./getDocumentElement.js";import isScrollParent from"./isScrollParent.js";import{round}from"../utils/math.js";function isElementScaled(e){var t=e.getBoundingClientRect(),o=round(t.width)/e.offsetWidth||1,t=round(t.height)/e.offsetHeight||1;return 1!==o||1!==t}export default function getCompositeRect(e,t,o){void 0===o&&(o=!1);var l=isHTMLElement(t),i=isHTMLElement(t)&&isElementScaled(t),n=getDocumentElement(t),e=getBoundingClientRect(e,i,o),i={scrollLeft:0,scrollTop:0},r={x:0,y:0};return!l&&o||("body"===getNodeName(t)&&!isScrollParent(n)||(i=getNodeScroll(t)),isHTMLElement(t)?((r=getBoundingClientRect(t,!0)).x+=t.clientLeft,r.y+=t.clientTop):n&&(r.x=getWindowScrollBarX(n))),{x:e.left+i.scrollLeft-r.x,y:e.top+i.scrollTop-r.y,width:e.width,height:e.height}}

View File

@@ -0,0 +1,4 @@
import getWindow from "./getWindow.js";
export default function getComputedStyle(element) {
return getWindow(element).getComputedStyle(element);
}

View File

@@ -0,0 +1 @@
import getWindow from"./getWindow.js";export default function getComputedStyle(t){return getWindow(t).getComputedStyle(t)}

View File

@@ -0,0 +1,6 @@
import { isElement } from "./instanceOf.js";
export default function getDocumentElement(element) {
// $FlowFixMe[incompatible-return]: assume body is always available
return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
element.document) || window.document).documentElement;
}

View File

@@ -0,0 +1 @@
import{isElement}from"./instanceOf.js";export default function getDocumentElement(e){return((isElement(e)?e.ownerDocument:e.document)||window.document).documentElement}

View File

@@ -0,0 +1,29 @@
import getDocumentElement from "./getDocumentElement.js";
import getComputedStyle from "./getComputedStyle.js";
import getWindowScrollBarX from "./getWindowScrollBarX.js";
import getWindowScroll from "./getWindowScroll.js";
import { max } from "../utils/math.js"; // Gets the entire size of the scrollable document area, even extending outside
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
export default function getDocumentRect(element) {
var _element$ownerDocumen;
var html = getDocumentElement(element);
var winScroll = getWindowScroll(element);
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
var y = -winScroll.scrollTop;
if (getComputedStyle(body || html).direction === 'rtl') {
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
}
return {
width: width,
height: height,
x: x,
y: y
};
}

View File

@@ -0,0 +1 @@
import getDocumentElement from"./getDocumentElement.js";import getComputedStyle from"./getComputedStyle.js";import getWindowScrollBarX from"./getWindowScrollBarX.js";import getWindowScroll from"./getWindowScroll.js";import{max}from"../utils/math.js";export default function getDocumentRect(t){var e=getDocumentElement(t),o=getWindowScroll(t),l=null==(l=t.ownerDocument)?void 0:l.body,i=max(e.scrollWidth,e.clientWidth,l?l.scrollWidth:0,l?l.clientWidth:0),r=max(e.scrollHeight,e.clientHeight,l?l.scrollHeight:0,l?l.clientHeight:0),t=-o.scrollLeft+getWindowScrollBarX(t),o=-o.scrollTop;return"rtl"===getComputedStyle(l||e).direction&&(t+=max(e.clientWidth,l?l.clientWidth:0)-i),{width:i,height:r,x:t,y:o}}

View File

@@ -0,0 +1,6 @@
export default function getHTMLElementScroll(element) {
return {
scrollLeft: element.scrollLeft,
scrollTop: element.scrollTop
};
}

View File

@@ -0,0 +1 @@
export default function getHTMLElementScroll(l){return{scrollLeft:l.scrollLeft,scrollTop:l.scrollTop}}

View File

@@ -0,0 +1,25 @@
import getBoundingClientRect from "./getBoundingClientRect.js"; // Returns the layout rect of an element relative to its offsetParent. Layout
// means it doesn't take into account transforms.
export default function getLayoutRect(element) {
var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
// Fixes https://github.com/popperjs/popper-core/issues/1223
var width = element.offsetWidth;
var height = element.offsetHeight;
if (Math.abs(clientRect.width - width) <= 1) {
width = clientRect.width;
}
if (Math.abs(clientRect.height - height) <= 1) {
height = clientRect.height;
}
return {
x: element.offsetLeft,
y: element.offsetTop,
width: width,
height: height
};
}

View File

@@ -0,0 +1 @@
import getBoundingClientRect from"./getBoundingClientRect.js";export default function getLayoutRect(t){var e=getBoundingClientRect(t),i=t.offsetWidth,h=t.offsetHeight;return Math.abs(e.width-i)<=1&&(i=e.width),Math.abs(e.height-h)<=1&&(h=e.height),{x:t.offsetLeft,y:t.offsetTop,width:i,height:h}}

View File

@@ -0,0 +1,3 @@
export default function getNodeName(element) {
return element ? (element.nodeName || '').toLowerCase() : null;
}

View File

@@ -0,0 +1 @@
export default function getNodeName(e){return e?(e.nodeName||"").toLowerCase():null}

View File

@@ -0,0 +1,11 @@
import getWindowScroll from "./getWindowScroll.js";
import getWindow from "./getWindow.js";
import { isHTMLElement } from "./instanceOf.js";
import getHTMLElementScroll from "./getHTMLElementScroll.js";
export default function getNodeScroll(node) {
if (node === getWindow(node) || !isHTMLElement(node)) {
return getWindowScroll(node);
} else {
return getHTMLElementScroll(node);
}
}

View File

@@ -0,0 +1 @@
import getWindowScroll from"./getWindowScroll.js";import getWindow from"./getWindow.js";import{isHTMLElement}from"./instanceOf.js";import getHTMLElementScroll from"./getHTMLElementScroll.js";export default function getNodeScroll(e){return(e!==getWindow(e)&&isHTMLElement(e)?getHTMLElementScroll:getWindowScroll)(e)}

View File

@@ -0,0 +1,69 @@
import getWindow from "./getWindow.js";
import getNodeName from "./getNodeName.js";
import getComputedStyle from "./getComputedStyle.js";
import { isHTMLElement, isShadowRoot } from "./instanceOf.js";
import isTableElement from "./isTableElement.js";
import getParentNode from "./getParentNode.js";
import getUAString from "../utils/userAgent.js";
function getTrueOffsetParent(element) {
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
getComputedStyle(element).position === 'fixed') {
return null;
}
return element.offsetParent;
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
// return the containing block
function getContainingBlock(element) {
var isFirefox = /firefox/i.test(getUAString());
var isIE = /Trident/i.test(getUAString());
if (isIE && isHTMLElement(element)) {
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
var elementCss = getComputedStyle(element);
if (elementCss.position === 'fixed') {
return null;
}
}
var currentNode = getParentNode(element);
if (isShadowRoot(currentNode)) {
currentNode = currentNode.host;
}
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
// create a containing block.
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
return currentNode;
} else {
currentNode = currentNode.parentNode;
}
}
return null;
} // Gets the closest ancestor positioned element. Handles some edge cases,
// such as table ancestors and cross browser bugs.
export default function getOffsetParent(element) {
var window = getWindow(element);
var offsetParent = getTrueOffsetParent(element);
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
offsetParent = getTrueOffsetParent(offsetParent);
}
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
return window;
}
return offsetParent || getContainingBlock(element) || window;
}

View File

@@ -0,0 +1 @@
import getWindow from"./getWindow.js";import getNodeName from"./getNodeName.js";import getComputedStyle from"./getComputedStyle.js";import{isHTMLElement,isShadowRoot}from"./instanceOf.js";import isTableElement from"./isTableElement.js";import getParentNode from"./getParentNode.js";import getUAString from"../utils/userAgent.js";function getTrueOffsetParent(e){return isHTMLElement(e)&&"fixed"!==getComputedStyle(e).position?e.offsetParent:null}function getContainingBlock(e){var t=/firefox/i.test(getUAString()),o=/Trident/i.test(getUAString());if(o&&isHTMLElement(e)&&"fixed"===getComputedStyle(e).position)return null;var n=getParentNode(e);for(isShadowRoot(n)&&(n=n.host);isHTMLElement(n)&&["html","body"].indexOf(getNodeName(n))<0;){var i=getComputedStyle(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}export default function getOffsetParent(e){for(var t=getWindow(e),o=getTrueOffsetParent(e);o&&isTableElement(o)&&"static"===getComputedStyle(o).position;)o=getTrueOffsetParent(o);return(!o||"html"!==getNodeName(o)&&("body"!==getNodeName(o)||"static"!==getComputedStyle(o).position))&&(o||getContainingBlock(e))||t}

View File

@@ -0,0 +1,19 @@
import getNodeName from "./getNodeName.js";
import getDocumentElement from "./getDocumentElement.js";
import { isShadowRoot } from "./instanceOf.js";
export default function getParentNode(element) {
if (getNodeName(element) === 'html') {
return element;
}
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
// $FlowFixMe[incompatible-return]
// $FlowFixMe[prop-missing]
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
element.parentNode || ( // DOM Element detected
isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
getDocumentElement(element) // fallback
);
}

View File

@@ -0,0 +1 @@
import getNodeName from"./getNodeName.js";import getDocumentElement from"./getDocumentElement.js";import{isShadowRoot}from"./instanceOf.js";export default function getParentNode(e){return"html"===getNodeName(e)?e:e.assignedSlot||e.parentNode||(isShadowRoot(e)?e.host:null)||getDocumentElement(e)}

View File

@@ -0,0 +1,16 @@
import getParentNode from "./getParentNode.js";
import isScrollParent from "./isScrollParent.js";
import getNodeName from "./getNodeName.js";
import { isHTMLElement } from "./instanceOf.js";
export default function getScrollParent(node) {
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
// $FlowFixMe[incompatible-return]: assume body is always available
return node.ownerDocument.body;
}
if (isHTMLElement(node) && isScrollParent(node)) {
return node;
}
return getScrollParent(getParentNode(node));
}

View File

@@ -0,0 +1 @@
import getParentNode from"./getParentNode.js";import isScrollParent from"./isScrollParent.js";import getNodeName from"./getNodeName.js";import{isHTMLElement}from"./instanceOf.js";export default function getScrollParent(e){return 0<=["html","body","#document"].indexOf(getNodeName(e))?e.ownerDocument.body:isHTMLElement(e)&&isScrollParent(e)?e:getScrollParent(getParentNode(e))}

View File

@@ -0,0 +1,31 @@
import getWindow from "./getWindow.js";
import getDocumentElement from "./getDocumentElement.js";
import getWindowScrollBarX from "./getWindowScrollBarX.js";
import isLayoutViewport from "./isLayoutViewport.js";
export default function getViewportRect(element, strategy) {
var win = getWindow(element);
var html = getDocumentElement(element);
var visualViewport = win.visualViewport;
var width = html.clientWidth;
var height = html.clientHeight;
var x = 0;
var y = 0;
if (visualViewport) {
width = visualViewport.width;
height = visualViewport.height;
var layoutViewport = isLayoutViewport();
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
x = visualViewport.offsetLeft;
y = visualViewport.offsetTop;
}
}
return {
width: width,
height: height,
x: x + getWindowScrollBarX(element),
y: y
};
}

View File

@@ -0,0 +1 @@
import getWindow from"./getWindow.js";import getDocumentElement from"./getDocumentElement.js";import getWindowScrollBarX from"./getWindowScrollBarX.js";import isLayoutViewport from"./isLayoutViewport.js";export default function getViewportRect(t,e){var o,i=getWindow(t),r=getDocumentElement(t),i=i.visualViewport,n=r.clientWidth,r=r.clientHeight,m=0,g=0;return i&&(n=i.width,r=i.height,((o=isLayoutViewport())||!o&&"fixed"===e)&&(m=i.offsetLeft,g=i.offsetTop)),{width:n,height:r,x:m+getWindowScrollBarX(t),y:g}}

View File

@@ -0,0 +1,12 @@
export default function getWindow(node) {
if (node == null) {
return window;
}
if (node.toString() !== '[object Window]') {
var ownerDocument = node.ownerDocument;
return ownerDocument ? ownerDocument.defaultView || window : window;
}
return node;
}

View File

@@ -0,0 +1 @@
export default function getWindow(n){return null==n?window:"[object Window]"!==n.toString()?(o=n.ownerDocument)&&o.defaultView||window:n;var o}

View File

@@ -0,0 +1,10 @@
import getWindow from "./getWindow.js";
export default function getWindowScroll(node) {
var win = getWindow(node);
var scrollLeft = win.pageXOffset;
var scrollTop = win.pageYOffset;
return {
scrollLeft: scrollLeft,
scrollTop: scrollTop
};
}

View File

@@ -0,0 +1 @@
import getWindow from"./getWindow.js";export default function getWindowScroll(e){e=getWindow(e);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}

View File

@@ -0,0 +1,13 @@
import getBoundingClientRect from "./getBoundingClientRect.js";
import getDocumentElement from "./getDocumentElement.js";
import getWindowScroll from "./getWindowScroll.js";
export default function getWindowScrollBarX(element) {
// If <html> has a CSS width greater than the viewport, then this will be
// incorrect for RTL.
// Popper 1 is broken in this case and never had a bug report so let's assume
// it's not an issue. I don't think anyone ever specifies width on <html>
// anyway.
// Browsers where the left scrollbar doesn't cause an issue report `0` for
// this (e.g. Edge 2019, IE11, Safari)
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
}

View File

@@ -0,0 +1 @@
import getBoundingClientRect from"./getBoundingClientRect.js";import getDocumentElement from"./getDocumentElement.js";import getWindowScroll from"./getWindowScroll.js";export default function getWindowScrollBarX(t){return getBoundingClientRect(getDocumentElement(t)).left+getWindowScroll(t).scrollLeft}

View File

@@ -0,0 +1,23 @@
import getWindow from "./getWindow.js";
function isElement(node) {
var OwnElement = getWindow(node).Element;
return node instanceof OwnElement || node instanceof Element;
}
function isHTMLElement(node) {
var OwnElement = getWindow(node).HTMLElement;
return node instanceof OwnElement || node instanceof HTMLElement;
}
function isShadowRoot(node) {
// IE 11 has no ShadowRoot
if (typeof ShadowRoot === 'undefined') {
return false;
}
var OwnElement = getWindow(node).ShadowRoot;
return node instanceof OwnElement || node instanceof ShadowRoot;
}
export { isElement, isHTMLElement, isShadowRoot };

View File

@@ -0,0 +1 @@
import getWindow from"./getWindow.js";function isElement(n){return n instanceof getWindow(n).Element||n instanceof Element}function isHTMLElement(n){return n instanceof getWindow(n).HTMLElement||n instanceof HTMLElement}function isShadowRoot(n){return"undefined"!=typeof ShadowRoot&&(n instanceof getWindow(n).ShadowRoot||n instanceof ShadowRoot)}export{isElement,isHTMLElement,isShadowRoot};

View File

@@ -0,0 +1,4 @@
import getUAString from "../utils/userAgent.js";
export default function isLayoutViewport() {
return !/^((?!chrome|android).)*safari/i.test(getUAString());
}

View File

@@ -0,0 +1 @@
import getUAString from"../utils/userAgent.js";export default function isLayoutViewport(){return!/^((?!chrome|android).)*safari/i.test(getUAString())}

View File

@@ -0,0 +1,10 @@
import getComputedStyle from "./getComputedStyle.js";
export default function isScrollParent(element) {
// Firefox wants us to check `-x` and `-y` variations as well
var _getComputedStyle = getComputedStyle(element),
overflow = _getComputedStyle.overflow,
overflowX = _getComputedStyle.overflowX,
overflowY = _getComputedStyle.overflowY;
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
}

View File

@@ -0,0 +1 @@
import getComputedStyle from"./getComputedStyle.js";export default function isScrollParent(e){var e=getComputedStyle(e),t=e.overflow,o=e.overflowX,e=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+e+o)}

View File

@@ -0,0 +1,4 @@
import getNodeName from "./getNodeName.js";
export default function isTableElement(element) {
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
}

View File

@@ -0,0 +1 @@
import getNodeName from"./getNodeName.js";export default function isTableElement(e){return 0<=["table","td","th"].indexOf(getNodeName(e))}

View File

@@ -0,0 +1,26 @@
import getScrollParent from "./getScrollParent.js";
import getParentNode from "./getParentNode.js";
import getWindow from "./getWindow.js";
import isScrollParent from "./isScrollParent.js";
/*
given a DOM element, return the list of all scroll parents, up the list of ancesors
until we get to the top window object. This list is what we attach scroll listeners
to, because if any of these parent elements scroll, we'll need to re-calculate the
reference element's position.
*/
export default function listScrollParents(element, list) {
var _element$ownerDocumen;
if (list === void 0) {
list = [];
}
var scrollParent = getScrollParent(element);
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
var win = getWindow(scrollParent);
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
var updatedList = list.concat(target);
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
updatedList.concat(listScrollParents(getParentNode(target)));
}

View File

@@ -0,0 +1 @@
import getScrollParent from"./getScrollParent.js";import getParentNode from"./getParentNode.js";import getWindow from"./getWindow.js";import isScrollParent from"./isScrollParent.js";export default function listScrollParents(t,o){void 0===o&&(o=[]);var r=getScrollParent(t),t=r===(null==(t=t.ownerDocument)?void 0:t.body),e=getWindow(r),e=t?[e].concat(e.visualViewport||[],isScrollParent(r)?r:[]):r,r=o.concat(e);return t?r:r.concat(listScrollParents(getParentNode(e)))}