@floating-ui/dom
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -13,2 +13,24 @@ import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core'; | ||
const min = Math.min; | ||
const max = Math.max; | ||
const round = Math.round; | ||
function getCssDimensions(element) { | ||
const css = getComputedStyle$1(element); | ||
let width = parseFloat(css.width); | ||
let height = parseFloat(css.height); | ||
const offsetWidth = element.offsetWidth; | ||
const offsetHeight = element.offsetHeight; | ||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; | ||
if (shouldFallback) { | ||
width = offsetWidth; | ||
height = offsetHeight; | ||
} | ||
return { | ||
width, | ||
height, | ||
fallback: shouldFallback | ||
}; | ||
} | ||
function getNodeName(node) { | ||
@@ -41,3 +63,3 @@ return isNode(node) ? (node.nodeName || '').toLowerCase() : ''; | ||
function isShadowRoot(node) { | ||
// Browsers without `ShadowRoot` support | ||
// Browsers without `ShadowRoot` support. | ||
if (typeof ShadowRoot === 'undefined') { | ||
@@ -62,3 +84,3 @@ return false; | ||
function isContainingBlock(element) { | ||
// TODO: Try and use feature detection here instead | ||
// TODO: Try to use feature detection here instead. | ||
const isFirefox = /firefox/i.test(getUAString()); | ||
@@ -71,5 +93,4 @@ const css = getComputedStyle$1(element); | ||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block | ||
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some( | ||
// TS 4.1 compat | ||
value => { | ||
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => { | ||
// Add type check for old browsers. | ||
const contain = css.contain; | ||
@@ -80,11 +101,11 @@ return contain != null ? contain.includes(value) : false; | ||
function isLayoutViewport() { | ||
// Not Safari | ||
// TODO: Try to use feature detection here instead. Feature detection for | ||
// this can fail in various ways, making the userAgent check the most: | ||
// reliable: | ||
// • Always-visible scrollbar or not | ||
// • Width of <html> | ||
// Not Safari. | ||
return !/^((?!chrome|android).)*safari/i.test(getUAString()); | ||
// Feature detection for this fails in various ways | ||
// • Always-visible scrollbar or not | ||
// • Width of <html>, etc. | ||
// const vV = win.visualViewport; | ||
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true; | ||
} | ||
function isLastTraversableNode(node) { | ||
@@ -94,24 +115,2 @@ return ['html', 'body', '#document'].includes(getNodeName(node)); | ||
const min = Math.min; | ||
const max = Math.max; | ||
const round = Math.round; | ||
function getCssDimensions(element) { | ||
const css = getComputedStyle$1(element); | ||
let width = parseFloat(css.width); | ||
let height = parseFloat(css.height); | ||
const offsetWidth = element.offsetWidth; | ||
const offsetHeight = element.offsetHeight; | ||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; | ||
if (shouldFallback) { | ||
width = offsetWidth; | ||
height = offsetHeight; | ||
} | ||
return { | ||
width, | ||
height, | ||
fallback: shouldFallback | ||
}; | ||
} | ||
function unwrapElement(element) { | ||
@@ -227,92 +226,2 @@ return !isElement(element) ? element.contextElement : element; | ||
function getWindowScrollBarX(element) { | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; | ||
} | ||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) { | ||
const isOffsetParentAnElement = isHTMLElement(offsetParent); | ||
const documentElement = getDocumentElement(offsetParent); | ||
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent); | ||
let scroll = { | ||
scrollLeft: 0, | ||
scrollTop: 0 | ||
}; | ||
const offsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') { | ||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { | ||
scroll = getNodeScroll(offsetParent); | ||
} | ||
if (isHTMLElement(offsetParent)) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
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 getParentNode(node) { | ||
if (getNodeName(node) === 'html') { | ||
return node; | ||
} | ||
const result = | ||
// Step into the shadow DOM of the parent of a slotted node | ||
node.assignedSlot || | ||
// DOM Element detected | ||
node.parentNode || ( | ||
// ShadowRoot detected | ||
isShadowRoot(node) ? node.host : null) || | ||
// Fallback | ||
getDocumentElement(node); | ||
return isShadowRoot(result) ? result.host : result; | ||
} | ||
function getTrueOffsetParent(element) { | ||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') { | ||
return null; | ||
} | ||
return element.offsetParent; | ||
} | ||
function getContainingBlock(element) { | ||
let currentNode = getParentNode(element); | ||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { | ||
if (isContainingBlock(currentNode)) { | ||
return currentNode; | ||
} else { | ||
currentNode = getParentNode(currentNode); | ||
} | ||
} | ||
return null; | ||
} | ||
// Gets the closest ancestor positioned element. Handles some edge cases, | ||
// such as table ancestors and cross browser bugs. | ||
function getOffsetParent(element) { | ||
const window = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
} | ||
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) { | ||
return window; | ||
} | ||
return offsetParent || getContainingBlock(element) || window; | ||
} | ||
function getDimensions(element) { | ||
return getCssDimensions(element); | ||
} | ||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { | ||
@@ -351,8 +260,3 @@ let { | ||
} | ||
// This doesn't appear to need to be negated. | ||
// else if (documentElement) { | ||
// offsets.x = getWindowScrollBarX(documentElement); | ||
// } | ||
} | ||
return { | ||
@@ -366,40 +270,20 @@ width: rect.width * scale.x, | ||
function getViewportRect(element, strategy) { | ||
const win = getWindow(element); | ||
const html = getDocumentElement(element); | ||
const visualViewport = win.visualViewport; | ||
let width = html.clientWidth; | ||
let height = html.clientHeight; | ||
let x = 0; | ||
let y = 0; | ||
if (visualViewport) { | ||
width = visualViewport.width; | ||
height = visualViewport.height; | ||
const layoutViewport = isLayoutViewport(); | ||
if (layoutViewport || !layoutViewport && strategy === 'fixed') { | ||
x = visualViewport.offsetLeft; | ||
y = visualViewport.offsetTop; | ||
} | ||
} | ||
return { | ||
width, | ||
height, | ||
x, | ||
y | ||
}; | ||
function getWindowScrollBarX(element) { | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; | ||
} | ||
// Gets the entire size of the scrollable document area, even extending outside | ||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable | ||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable. | ||
function getDocumentRect(element) { | ||
var _element$ownerDocumen; | ||
const html = getDocumentElement(element); | ||
const scroll = getNodeScroll(element); | ||
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body; | ||
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0); | ||
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0); | ||
const body = element.ownerDocument.body; | ||
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); | ||
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); | ||
let x = -scroll.scrollLeft + getWindowScrollBarX(element); | ||
const y = -scroll.scrollTop; | ||
if (getComputedStyle$1(body || html).direction === 'rtl') { | ||
x += max(html.clientWidth, body ? body.clientWidth : 0) - width; | ||
if (getComputedStyle$1(body).direction === 'rtl') { | ||
x += max(html.clientWidth, body.clientWidth) - width; | ||
} | ||
@@ -414,7 +298,24 @@ return { | ||
function getParentNode(node) { | ||
if (getNodeName(node) === 'html') { | ||
return node; | ||
} | ||
const result = | ||
// Step into the shadow DOM of the parent of a slotted node. | ||
node.assignedSlot || | ||
// DOM Element detected. | ||
node.parentNode || | ||
// ShadowRoot detected. | ||
isShadowRoot(node) && node.host || | ||
// Fallback. | ||
getDocumentElement(node); | ||
return isShadowRoot(result) ? result.host : result; | ||
} | ||
function getNearestOverflowAncestor(node) { | ||
const parentNode = getParentNode(node); | ||
if (isLastTraversableNode(parentNode)) { | ||
// @ts-ignore assume body is always available | ||
return node.ownerDocument.body; | ||
// `getParentNode` will never return a `Document` due to the fallback | ||
// check, so it's either the <html> or <body> element. | ||
return parentNode.ownerDocument.body; | ||
} | ||
@@ -441,3 +342,28 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { | ||
// Returns the inner client rect, subtracting scrollbars if present | ||
function getViewportRect(element, strategy) { | ||
const win = getWindow(element); | ||
const html = getDocumentElement(element); | ||
const visualViewport = win.visualViewport; | ||
let width = html.clientWidth; | ||
let height = html.clientHeight; | ||
let x = 0; | ||
let y = 0; | ||
if (visualViewport) { | ||
width = visualViewport.width; | ||
height = visualViewport.height; | ||
const layoutViewport = isLayoutViewport(); | ||
if (layoutViewport || !layoutViewport && strategy === 'fixed') { | ||
x = visualViewport.offsetLeft; | ||
y = visualViewport.offsetTop; | ||
} | ||
} | ||
return { | ||
width, | ||
height, | ||
x, | ||
y | ||
}; | ||
} | ||
// Returns the inner client rect, subtracting scrollbars if present. | ||
function getInnerBoundingClientRect(element, strategy) { | ||
@@ -456,10 +382,6 @@ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed'); | ||
return { | ||
top: y, | ||
left: x, | ||
right: x + width, | ||
bottom: y + height, | ||
width, | ||
height, | ||
x, | ||
y, | ||
width, | ||
height | ||
y | ||
}; | ||
@@ -472,3 +394,3 @@ } | ||
if (isElement(clippingAncestor)) { | ||
return getInnerBoundingClientRect(clippingAncestor, strategy); | ||
return rectToClientRect(getInnerBoundingClientRect(clippingAncestor, strategy)); | ||
} | ||
@@ -497,6 +419,6 @@ return rectToClientRect(getDocumentRect(getDocumentElement(element))); | ||
if (shouldDropCurrentNode) { | ||
// Drop non-containing blocks | ||
// Drop non-containing blocks. | ||
result = result.filter(ancestor => ancestor !== currentNode); | ||
} else { | ||
// Record last containing block for next iteration | ||
// Record last containing block for next iteration. | ||
currentContainingBlockComputedStyle = computedStyle; | ||
@@ -511,3 +433,3 @@ } | ||
// Gets the maximum area that the element is visible in due to any number of | ||
// clipping ancestors | ||
// clipping ancestors. | ||
function getClippingRect(_ref) { | ||
@@ -539,2 +461,73 @@ let { | ||
function getDimensions(element) { | ||
if (isHTMLElement(element)) { | ||
return getCssDimensions(element); | ||
} | ||
return element.getBoundingClientRect(); | ||
} | ||
function getTrueOffsetParent(element) { | ||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') { | ||
return null; | ||
} | ||
return element.offsetParent; | ||
} | ||
function getContainingBlock(element) { | ||
let currentNode = getParentNode(element); | ||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { | ||
if (isContainingBlock(currentNode)) { | ||
return currentNode; | ||
} else { | ||
currentNode = getParentNode(currentNode); | ||
} | ||
} | ||
return null; | ||
} | ||
// Gets the closest ancestor positioned element. Handles some edge cases, | ||
// such as table ancestors and cross browser bugs. | ||
function getOffsetParent(element) { | ||
const window = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
} | ||
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) { | ||
return window; | ||
} | ||
return offsetParent || getContainingBlock(element) || window; | ||
} | ||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) { | ||
const isOffsetParentAnElement = isHTMLElement(offsetParent); | ||
const documentElement = getDocumentElement(offsetParent); | ||
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent); | ||
let scroll = { | ||
scrollLeft: 0, | ||
scrollTop: 0 | ||
}; | ||
const offsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') { | ||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { | ||
scroll = getNodeScroll(offsetParent); | ||
} | ||
if (isHTMLElement(offsetParent)) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
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 | ||
}; | ||
} | ||
const platform = { | ||
@@ -541,0 +534,0 @@ getClippingRect, |
@@ -16,2 +16,24 @@ (function (global, factory) { | ||
const min = Math.min; | ||
const max = Math.max; | ||
const round = Math.round; | ||
function getCssDimensions(element) { | ||
const css = getComputedStyle$1(element); | ||
let width = parseFloat(css.width); | ||
let height = parseFloat(css.height); | ||
const offsetWidth = element.offsetWidth; | ||
const offsetHeight = element.offsetHeight; | ||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; | ||
if (shouldFallback) { | ||
width = offsetWidth; | ||
height = offsetHeight; | ||
} | ||
return { | ||
width, | ||
height, | ||
fallback: shouldFallback | ||
}; | ||
} | ||
function getNodeName(node) { | ||
@@ -44,3 +66,3 @@ return isNode(node) ? (node.nodeName || '').toLowerCase() : ''; | ||
function isShadowRoot(node) { | ||
// Browsers without `ShadowRoot` support | ||
// Browsers without `ShadowRoot` support. | ||
if (typeof ShadowRoot === 'undefined') { | ||
@@ -65,3 +87,3 @@ return false; | ||
function isContainingBlock(element) { | ||
// TODO: Try and use feature detection here instead | ||
// TODO: Try to use feature detection here instead. | ||
const isFirefox = /firefox/i.test(getUAString()); | ||
@@ -74,5 +96,4 @@ const css = getComputedStyle$1(element); | ||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block | ||
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some( | ||
// TS 4.1 compat | ||
value => { | ||
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => { | ||
// Add type check for old browsers. | ||
const contain = css.contain; | ||
@@ -83,11 +104,11 @@ return contain != null ? contain.includes(value) : false; | ||
function isLayoutViewport() { | ||
// Not Safari | ||
// TODO: Try to use feature detection here instead. Feature detection for | ||
// this can fail in various ways, making the userAgent check the most: | ||
// reliable: | ||
// • Always-visible scrollbar or not | ||
// • Width of <html> | ||
// Not Safari. | ||
return !/^((?!chrome|android).)*safari/i.test(getUAString()); | ||
// Feature detection for this fails in various ways | ||
// • Always-visible scrollbar or not | ||
// • Width of <html>, etc. | ||
// const vV = win.visualViewport; | ||
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true; | ||
} | ||
function isLastTraversableNode(node) { | ||
@@ -97,24 +118,2 @@ return ['html', 'body', '#document'].includes(getNodeName(node)); | ||
const min = Math.min; | ||
const max = Math.max; | ||
const round = Math.round; | ||
function getCssDimensions(element) { | ||
const css = getComputedStyle$1(element); | ||
let width = parseFloat(css.width); | ||
let height = parseFloat(css.height); | ||
const offsetWidth = element.offsetWidth; | ||
const offsetHeight = element.offsetHeight; | ||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; | ||
if (shouldFallback) { | ||
width = offsetWidth; | ||
height = offsetHeight; | ||
} | ||
return { | ||
width, | ||
height, | ||
fallback: shouldFallback | ||
}; | ||
} | ||
function unwrapElement(element) { | ||
@@ -230,92 +229,2 @@ return !isElement(element) ? element.contextElement : element; | ||
function getWindowScrollBarX(element) { | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; | ||
} | ||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) { | ||
const isOffsetParentAnElement = isHTMLElement(offsetParent); | ||
const documentElement = getDocumentElement(offsetParent); | ||
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent); | ||
let scroll = { | ||
scrollLeft: 0, | ||
scrollTop: 0 | ||
}; | ||
const offsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') { | ||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { | ||
scroll = getNodeScroll(offsetParent); | ||
} | ||
if (isHTMLElement(offsetParent)) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
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 getParentNode(node) { | ||
if (getNodeName(node) === 'html') { | ||
return node; | ||
} | ||
const result = | ||
// Step into the shadow DOM of the parent of a slotted node | ||
node.assignedSlot || | ||
// DOM Element detected | ||
node.parentNode || ( | ||
// ShadowRoot detected | ||
isShadowRoot(node) ? node.host : null) || | ||
// Fallback | ||
getDocumentElement(node); | ||
return isShadowRoot(result) ? result.host : result; | ||
} | ||
function getTrueOffsetParent(element) { | ||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') { | ||
return null; | ||
} | ||
return element.offsetParent; | ||
} | ||
function getContainingBlock(element) { | ||
let currentNode = getParentNode(element); | ||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { | ||
if (isContainingBlock(currentNode)) { | ||
return currentNode; | ||
} else { | ||
currentNode = getParentNode(currentNode); | ||
} | ||
} | ||
return null; | ||
} | ||
// Gets the closest ancestor positioned element. Handles some edge cases, | ||
// such as table ancestors and cross browser bugs. | ||
function getOffsetParent(element) { | ||
const window = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
} | ||
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) { | ||
return window; | ||
} | ||
return offsetParent || getContainingBlock(element) || window; | ||
} | ||
function getDimensions(element) { | ||
return getCssDimensions(element); | ||
} | ||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { | ||
@@ -354,8 +263,3 @@ let { | ||
} | ||
// This doesn't appear to need to be negated. | ||
// else if (documentElement) { | ||
// offsets.x = getWindowScrollBarX(documentElement); | ||
// } | ||
} | ||
return { | ||
@@ -369,40 +273,20 @@ width: rect.width * scale.x, | ||
function getViewportRect(element, strategy) { | ||
const win = getWindow(element); | ||
const html = getDocumentElement(element); | ||
const visualViewport = win.visualViewport; | ||
let width = html.clientWidth; | ||
let height = html.clientHeight; | ||
let x = 0; | ||
let y = 0; | ||
if (visualViewport) { | ||
width = visualViewport.width; | ||
height = visualViewport.height; | ||
const layoutViewport = isLayoutViewport(); | ||
if (layoutViewport || !layoutViewport && strategy === 'fixed') { | ||
x = visualViewport.offsetLeft; | ||
y = visualViewport.offsetTop; | ||
} | ||
} | ||
return { | ||
width, | ||
height, | ||
x, | ||
y | ||
}; | ||
function getWindowScrollBarX(element) { | ||
// If <html> has a CSS width greater than the viewport, then this will be | ||
// incorrect for RTL. | ||
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; | ||
} | ||
// Gets the entire size of the scrollable document area, even extending outside | ||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable | ||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable. | ||
function getDocumentRect(element) { | ||
var _element$ownerDocumen; | ||
const html = getDocumentElement(element); | ||
const scroll = getNodeScroll(element); | ||
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body; | ||
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0); | ||
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0); | ||
const body = element.ownerDocument.body; | ||
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); | ||
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); | ||
let x = -scroll.scrollLeft + getWindowScrollBarX(element); | ||
const y = -scroll.scrollTop; | ||
if (getComputedStyle$1(body || html).direction === 'rtl') { | ||
x += max(html.clientWidth, body ? body.clientWidth : 0) - width; | ||
if (getComputedStyle$1(body).direction === 'rtl') { | ||
x += max(html.clientWidth, body.clientWidth) - width; | ||
} | ||
@@ -417,7 +301,24 @@ return { | ||
function getParentNode(node) { | ||
if (getNodeName(node) === 'html') { | ||
return node; | ||
} | ||
const result = | ||
// Step into the shadow DOM of the parent of a slotted node. | ||
node.assignedSlot || | ||
// DOM Element detected. | ||
node.parentNode || | ||
// ShadowRoot detected. | ||
isShadowRoot(node) && node.host || | ||
// Fallback. | ||
getDocumentElement(node); | ||
return isShadowRoot(result) ? result.host : result; | ||
} | ||
function getNearestOverflowAncestor(node) { | ||
const parentNode = getParentNode(node); | ||
if (isLastTraversableNode(parentNode)) { | ||
// @ts-ignore assume body is always available | ||
return node.ownerDocument.body; | ||
// `getParentNode` will never return a `Document` due to the fallback | ||
// check, so it's either the <html> or <body> element. | ||
return parentNode.ownerDocument.body; | ||
} | ||
@@ -444,3 +345,28 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { | ||
// Returns the inner client rect, subtracting scrollbars if present | ||
function getViewportRect(element, strategy) { | ||
const win = getWindow(element); | ||
const html = getDocumentElement(element); | ||
const visualViewport = win.visualViewport; | ||
let width = html.clientWidth; | ||
let height = html.clientHeight; | ||
let x = 0; | ||
let y = 0; | ||
if (visualViewport) { | ||
width = visualViewport.width; | ||
height = visualViewport.height; | ||
const layoutViewport = isLayoutViewport(); | ||
if (layoutViewport || !layoutViewport && strategy === 'fixed') { | ||
x = visualViewport.offsetLeft; | ||
y = visualViewport.offsetTop; | ||
} | ||
} | ||
return { | ||
width, | ||
height, | ||
x, | ||
y | ||
}; | ||
} | ||
// Returns the inner client rect, subtracting scrollbars if present. | ||
function getInnerBoundingClientRect(element, strategy) { | ||
@@ -459,10 +385,6 @@ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed'); | ||
return { | ||
top: y, | ||
left: x, | ||
right: x + width, | ||
bottom: y + height, | ||
width, | ||
height, | ||
x, | ||
y, | ||
width, | ||
height | ||
y | ||
}; | ||
@@ -475,3 +397,3 @@ } | ||
if (isElement(clippingAncestor)) { | ||
return getInnerBoundingClientRect(clippingAncestor, strategy); | ||
return core.rectToClientRect(getInnerBoundingClientRect(clippingAncestor, strategy)); | ||
} | ||
@@ -500,6 +422,6 @@ return core.rectToClientRect(getDocumentRect(getDocumentElement(element))); | ||
if (shouldDropCurrentNode) { | ||
// Drop non-containing blocks | ||
// Drop non-containing blocks. | ||
result = result.filter(ancestor => ancestor !== currentNode); | ||
} else { | ||
// Record last containing block for next iteration | ||
// Record last containing block for next iteration. | ||
currentContainingBlockComputedStyle = computedStyle; | ||
@@ -514,3 +436,3 @@ } | ||
// Gets the maximum area that the element is visible in due to any number of | ||
// clipping ancestors | ||
// clipping ancestors. | ||
function getClippingRect(_ref) { | ||
@@ -542,2 +464,73 @@ let { | ||
function getDimensions(element) { | ||
if (isHTMLElement(element)) { | ||
return getCssDimensions(element); | ||
} | ||
return element.getBoundingClientRect(); | ||
} | ||
function getTrueOffsetParent(element) { | ||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') { | ||
return null; | ||
} | ||
return element.offsetParent; | ||
} | ||
function getContainingBlock(element) { | ||
let currentNode = getParentNode(element); | ||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { | ||
if (isContainingBlock(currentNode)) { | ||
return currentNode; | ||
} else { | ||
currentNode = getParentNode(currentNode); | ||
} | ||
} | ||
return null; | ||
} | ||
// Gets the closest ancestor positioned element. Handles some edge cases, | ||
// such as table ancestors and cross browser bugs. | ||
function getOffsetParent(element) { | ||
const window = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
} | ||
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) { | ||
return window; | ||
} | ||
return offsetParent || getContainingBlock(element) || window; | ||
} | ||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) { | ||
const isOffsetParentAnElement = isHTMLElement(offsetParent); | ||
const documentElement = getDocumentElement(offsetParent); | ||
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent); | ||
let scroll = { | ||
scrollLeft: 0, | ||
scrollTop: 0 | ||
}; | ||
const offsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') { | ||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { | ||
scroll = getNodeScroll(offsetParent); | ||
} | ||
if (isHTMLElement(offsetParent)) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
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 | ||
}; | ||
} | ||
const platform = { | ||
@@ -544,0 +537,0 @@ getClippingRect, |
@@ -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 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|clip/.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=Math.min,y=Math.max,b=Math.round;function w(t){const e=o(t);let n=parseFloat(e.width),i=parseFloat(e.height);const r=t.offsetWidth,l=t.offsetHeight,c=b(n)!==r||b(i)!==l;return c&&(n=r,i=l),{width:n,height:i,fallback:c}}function x(t){return f(t)?t:t.contextElement}const v={x:1,y:1};function L(t){const e=x(t);if(!c(e))return v;const n=e.getBoundingClientRect(),{width:o,height:i,fallback:r}=w(e);let l=(r?b(n.width):n.width)/o,f=(r?b(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),f&&Number.isFinite(f)||(f=1),{x:l,y:f}}function T(t,e,o,i){var r,l;void 0===e&&(e=!1),void 0===o&&(o=!1);const c=t.getBoundingClientRect(),s=x(t);let u=v;e&&(i?f(i)&&(u=L(i)):u=L(t));const a=s?n(s):window,d=!p()&&o;let h=(c.left+(d&&(null==(r=a.visualViewport)?void 0:r.offsetLeft)||0))/u.x,g=(c.top+(d&&(null==(l=a.visualViewport)?void 0:l.offsetTop)||0))/u.y,m=c.width/u.x,y=c.height/u.y;if(s){const t=n(s),e=i&&f(i)?n(i):i;let o=t.frameElement;for(;o&&i&&e!==t;){const t=L(o),e=o.getBoundingClientRect(),i=getComputedStyle(o);e.x+=(o.clientLeft+parseFloat(i.paddingLeft))*t.x,e.y+=(o.clientTop+parseFloat(i.paddingTop))*t.y,h*=t.x,g*=t.y,m*=t.x,y*=t.y,h+=e.x,g+=e.y,o=n(o).frameElement}}return{width:m,height:y,top:g,right:h+m,bottom:g+y,left:h,x:h,y:g}}function O(t){return((s(t)?t.ownerDocument:t.document)||window.document).documentElement}function P(t){return f(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function R(t){return T(O(t)).left+P(t).scrollLeft}function E(t,e,n){const o=c(e),r=O(e),l=T(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=P(e)),c(e)){const t=T(e,!0);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else r&&(s.x=R(r));return{x:l.left+f.scrollLeft-s.x,y:l.top+f.scrollTop-s.y,width:l.width,height:l.height}}function C(t){if("html"===i(t))return t;const e=t.assignedSlot||t.parentNode||(u(t)?t.host:null)||O(t);return u(e)?e.host:e}function j(t){return c(t)&&"fixed"!==o(t).position?t.offsetParent:null}function F(t){const e=n(t);let r=j(t);for(;r&&d(r)&&"static"===o(r).position;)r=j(r);return r&&("html"===i(r)||"body"===i(r)&&"static"===o(r).position&&!h(r))?e:r||function(t){let e=C(t);for(;c(e)&&!g(e);){if(h(e))return e;e=C(e)}return null}(t)||e}function D(t){const e=C(t);return g(e)?t.ownerDocument.body:c(e)&&a(e)?e:D(e)}function S(t,e){var o;void 0===e&&(e=[]);const i=D(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,S(i))}function W(t,i,r){return"viewport"===i?e.rectToClientRect(function(t,e){const o=n(t),i=O(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=T(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?L(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=O(t),i=P(t),r=null==(e=t.ownerDocument)?void 0:e.body,l=y(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),c=y(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let f=-i.scrollLeft+R(t);const s=-i.scrollTop;return"rtl"===o(r||n).direction&&(f+=y(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:c,x:f,y:s}}(O(t)))}const A={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=S(t).filter((t=>f(t)&&"body"!==i(t))),l=null;const c="fixed"===o(t).position;let s=c?C(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=C(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=W(e,n,l);return t.top=y(o.top,t.top),t.right=m(o.right,t.right),t.bottom=m(o.bottom,t.bottom),t.left=y(o.left,t.left),t}),W(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=O(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=P(n)),c(n))){const t=T(n);s=L(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){return w(t)},getOffsetParent:F,getDocumentElement:O,getScale:L,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||F,r=this.getDimensions;return{reference:E(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)?S(t):t.contextElement?S(t.contextElement):[],...S(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?T(t):null;return c&&function e(){const o=T(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:A,...o},l={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:l})},t.getOverflowAncestors=S,t.platform=A,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)}const i=Math.min,r=Math.max,l=Math.round;function c(t){const e=o(t);let n=parseFloat(e.width),i=parseFloat(e.height);const r=t.offsetWidth,c=t.offsetHeight,f=l(n)!==r||l(i)!==c;return f&&(n=r,i=c),{width:n,height:i,fallback:f}}function f(t){return h(t)?(t.nodeName||"").toLowerCase():""}let s;function u(){if(s)return s;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(s=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),s):navigator.userAgent}function a(t){return t instanceof n(t).HTMLElement}function d(t){return t instanceof n(t).Element}function h(t){return t instanceof n(t).Node}function p(t){if("undefined"==typeof ShadowRoot)return!1;return t instanceof n(t).ShadowRoot||t instanceof ShadowRoot}function g(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 m(t){return["table","td","th"].includes(f(t))}function y(t){const e=/firefox/i.test(u()),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 w(){return!/^((?!chrome|android).)*safari/i.test(u())}function x(t){return["html","body","#document"].includes(f(t))}function b(t){return d(t)?t:t.contextElement}const v={x:1,y:1};function L(t){const e=b(t);if(!a(e))return v;const n=e.getBoundingClientRect(),{width:o,height:i,fallback:r}=c(e);let f=(r?l(n.width):n.width)/o,s=(r?l(n.height):n.height)/i;return f&&Number.isFinite(f)||(f=1),s&&Number.isFinite(s)||(s=1),{x:f,y:s}}function T(t,e,o,i){var r,l;void 0===e&&(e=!1),void 0===o&&(o=!1);const c=t.getBoundingClientRect(),f=b(t);let s=v;e&&(i?d(i)&&(s=L(i)):s=L(t));const u=f?n(f):window,a=!w()&&o;let h=(c.left+(a&&(null==(r=u.visualViewport)?void 0:r.offsetLeft)||0))/s.x,p=(c.top+(a&&(null==(l=u.visualViewport)?void 0:l.offsetTop)||0))/s.y,g=c.width/s.x,m=c.height/s.y;if(f){const t=n(f),e=i&&d(i)?n(i):i;let o=t.frameElement;for(;o&&i&&e!==t;){const t=L(o),e=o.getBoundingClientRect(),i=getComputedStyle(o);e.x+=(o.clientLeft+parseFloat(i.paddingLeft))*t.x,e.y+=(o.clientTop+parseFloat(i.paddingTop))*t.y,h*=t.x,p*=t.y,g*=t.x,m*=t.y,h+=e.x,p+=e.y,o=n(o).frameElement}}return{width:g,height:m,top:p,right:h+g,bottom:p+m,left:h,x:h,y:p}}function R(t){return((h(t)?t.ownerDocument:t.document)||window.document).documentElement}function O(t){return d(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function P(t){return T(R(t)).left+O(t).scrollLeft}function E(t){if("html"===f(t))return t;const e=t.assignedSlot||t.parentNode||p(t)&&t.host||R(t);return p(e)?e.host:e}function C(t){const e=E(t);return x(e)?e.ownerDocument.body:a(e)&&g(e)?e:C(e)}function j(t,e){var o;void 0===e&&(e=[]);const i=C(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=n(i);return r?e.concat(l,l.visualViewport||[],g(i)?i:[]):e.concat(i,j(i))}function F(t,i,l){return"viewport"===i?e.rectToClientRect(function(t,e){const o=n(t),i=R(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=w();(t||!t&&"fixed"===e)&&(f=r.offsetLeft,s=r.offsetTop)}return{width:l,height:c,x:f,y:s}}(t,l)):d(i)?e.rectToClientRect(function(t,e){const n=T(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=a(t)?L(t):{x:1,y:1};return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(i,l)):e.rectToClientRect(function(t){const e=R(t),n=O(t),i=t.ownerDocument.body,l=r(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=r(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let f=-n.scrollLeft+P(t);const s=-n.scrollTop;return"rtl"===o(i).direction&&(f+=r(e.clientWidth,i.clientWidth)-l),{width:l,height:c,x:f,y:s}}(R(t)))}function D(t){return a(t)&&"fixed"!==o(t).position?t.offsetParent:null}function S(t){const e=n(t);let i=D(t);for(;i&&m(i)&&"static"===o(i).position;)i=D(i);return i&&("html"===f(i)||"body"===f(i)&&"static"===o(i).position&&!y(i))?e:i||function(t){let e=E(t);for(;a(e)&&!x(e);){if(y(e))return e;e=E(e)}return null}(t)||e}function W(t,e,n){const o=a(e),i=R(e),r=T(t,!0,"fixed"===n,e);let l={scrollLeft:0,scrollTop:0};const c={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==f(e)||g(i))&&(l=O(e)),a(e)){const t=T(e,!0);c.x=t.x+e.clientLeft,c.y=t.y+e.clientTop}else i&&(c.x=P(i));return{x:r.left+l.scrollLeft-c.x,y:r.top+l.scrollTop-c.y,width:r.width,height:r.height}}const A={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:l,strategy:c}=t;const s="clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let i=j(t).filter((t=>d(t)&&"body"!==f(t))),r=null;const l="fixed"===o(t).position;let c=l?E(t):t;for(;d(c)&&!x(c);){const t=o(c),e=y(c);(l?e||r:e||"static"!==t.position||!r||!["absolute","fixed"].includes(r.position))?r=t:i=i.filter((t=>t!==c)),c=E(c)}return e.set(t,i),i}(e,this._c):[].concat(n),u=[...s,l],a=u[0],h=u.reduce(((t,n)=>{const o=F(e,n,c);return t.top=r(o.top,t.top),t.right=i(o.right,t.right),t.bottom=i(o.bottom,t.bottom),t.left=r(o.left,t.left),t}),F(e,a,c));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=a(n),r=R(n);if(n===r)return e;let l={scrollLeft:0,scrollTop:0},c={x:1,y:1};const s={x:0,y:0};if((i||!i&&"fixed"!==o)&&(("body"!==f(n)||g(r))&&(l=O(n)),a(n))){const t=T(n);c=L(n),s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+s.x,y:e.y*c.y-l.scrollTop*c.y+s.y}},isElement:d,getDimensions:function(t){return a(t)?c(t):t.getBoundingClientRect()},getOffsetParent:S,getDocumentElement:R,getScale:L,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||S,r=this.getDimensions;return{reference:W(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,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?T(t):null;return c&&function e(){const o=T(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)=>{const i=new Map,r={platform:A,...o},l={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:l})},t.getOverflowAncestors=j,t.platform=A,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/dom", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"@rollingversions": { | ||
@@ -63,3 +63,3 @@ "baseVersion": [ | ||
"dependencies": { | ||
"@floating-ui/core": "^1.0.5" | ||
"@floating-ui/core": "^1.1.0" | ||
}, | ||
@@ -66,0 +66,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
import type { ReferenceElement, FloatingElement } from './types'; | ||
import type { FloatingElement, ReferenceElement } from './types'; | ||
export interface Options { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { ComputePositionConfig, ReferenceElement, FloatingElement } from './types'; | ||
import type { ComputePositionConfig, FloatingElement, ReferenceElement } from './types'; | ||
/** | ||
@@ -8,5 +8,5 @@ * Computes the `x` and `y` coordinates that will place the floating element | ||
export declare const computePosition: (reference: ReferenceElement, floating: FloatingElement, options?: Partial<ComputePositionConfig>) => Promise<import("@floating-ui/core").ComputePositionReturn>; | ||
export { arrow, autoPlacement, flip, hide, offset, shift, limitShift, size, inline, detectOverflow, } from '@floating-ui/core'; | ||
export { autoUpdate } from './autoUpdate'; | ||
export { platform } from './platform'; | ||
export { getOverflowAncestors } from './utils/getOverflowAncestors'; | ||
export { platform } from './platform'; | ||
export { arrow, autoPlacement, detectOverflow, flip, hide, inline, limitShift, offset, shift, size, } from '@floating-ui/core'; |
@@ -1,2 +0,2 @@ | ||
import type { AutoPlacementOptions, ClientRectObject, DetectOverflowOptions as CoreDetectOverflowOptions, Dimensions, ElementRects, FlipOptions, HideOptions, Middleware as CoreMiddleware, MiddlewareArguments as CoreMiddlewareArguments, MiddlewareReturn, Padding, Rect, RootBoundary, ShiftOptions, SideObject, SizeOptions as CoreSizeOptions, Strategy, ComputePositionConfig as CoreComputePositionConfig } from '@floating-ui/core'; | ||
import type { AutoPlacementOptions, ClientRectObject, ComputePositionConfig as CoreComputePositionConfig, DetectOverflowOptions as CoreDetectOverflowOptions, Dimensions, ElementRects, FlipOptions, HideOptions, Middleware as CoreMiddleware, MiddlewareArguments as CoreMiddlewareArguments, MiddlewareReturn, Padding, Rect, RootBoundary, ShiftOptions, SideObject, SizeOptions as CoreSizeOptions, Strategy } from '@floating-ui/core'; | ||
type Promisable<T> = T | Promise<T>; | ||
@@ -15,3 +15,3 @@ export interface Platform { | ||
}) => Promisable<Rect>; | ||
getDimensions: (element: HTMLElement) => Promisable<Dimensions>; | ||
getDimensions: (element: Element) => Promisable<Dimensions>; | ||
convertOffsetParentRelativeRectToViewportRelativeRect?: (args: { | ||
@@ -105,3 +105,3 @@ rect: Rect; | ||
declare const arrow: (options: { | ||
element: HTMLElement; | ||
element: Element; | ||
padding?: Padding; | ||
@@ -124,8 +124,8 @@ }) => Middleware; | ||
declare const detectOverflow: (middlewareArguments: MiddlewareArguments, options?: Partial<DetectOverflowOptions>) => Promise<SideObject>; | ||
export { autoPlacement, shift, arrow, size, flip, hide, detectOverflow }; | ||
export { offset, limitShift, inline } from '@floating-ui/core'; | ||
export type { Placement, Strategy, Alignment, Side, AlignedPlacement, Axis, Length, Coords, SideObject, Dimensions, Rect, ElementRects, ElementContext, ClientRectObject, Padding, RootBoundary, MiddlewareReturn, MiddlewareData, ComputePositionReturn, } from '@floating-ui/core'; | ||
export { arrow, autoPlacement, detectOverflow, flip, hide, shift, size }; | ||
export { computePosition } from './'; | ||
export { autoUpdate, Options as AutoUpdateOptions } from './autoUpdate'; | ||
export { platform } from './platform'; | ||
export { getOverflowAncestors } from './utils/getOverflowAncestors'; | ||
export { platform } from './platform'; | ||
export type { AlignedPlacement, Alignment, Axis, ClientRectObject, ComputePositionReturn, Coords, Dimensions, ElementContext, ElementRects, Length, MiddlewareData, MiddlewareReturn, Padding, Placement, Rect, RootBoundary, Side, SideObject, Strategy, } from '@floating-ui/core'; | ||
export { inline, limitShift, offset } from '@floating-ui/core'; |
@@ -1,2 +0,2 @@ | ||
import { Boundary, RootBoundary, Rect, Strategy } from '@floating-ui/core'; | ||
import type { Boundary, Rect, RootBoundary, Strategy } from '@floating-ui/core'; | ||
import { Platform, ReferenceElement } from '../types'; | ||
@@ -3,0 +3,0 @@ type PlatformWithCache = Platform & { |
import type { Dimensions } from '@floating-ui/core'; | ||
export declare function getDimensions(element: HTMLElement): Dimensions; | ||
export declare function getDimensions(element: Element): Dimensions; |
@@ -1,1 +0,1 @@ | ||
export default function getWindowScrollBarX(element: Element): number; | ||
export declare function getWindowScrollBarX(element: Element): 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118331
2767
Updated@floating-ui/core@^1.1.0