@floating-ui/dom
Advanced tools
Comparing version 1.2.8 to 1.2.9
@@ -20,15 +20,2 @@ import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core'; | ||
let uaString; | ||
function getUAString() { | ||
if (uaString) { | ||
return uaString; | ||
} | ||
const uaData = navigator.userAgentData; | ||
if (uaData && Array.isArray(uaData.brands)) { | ||
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' '); | ||
return uaString; | ||
} | ||
return navigator.userAgent; | ||
} | ||
function isHTMLElement(value) { | ||
@@ -61,32 +48,11 @@ return value instanceof getWindow(value).HTMLElement; | ||
function isContainingBlock(element) { | ||
// TODO: Try to use feature detection here instead. | ||
const isFirefox = /firefox/i.test(getUAString()); | ||
const safari = isSafari(); | ||
const css = getComputedStyle$1(element); | ||
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter; | ||
// 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 | ||
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; | ||
return contain != null ? contain.includes(value) : false; | ||
}); | ||
return css.transform !== 'none' || css.perspective !== 'none' || !safari && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !safari && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value)); | ||
} | ||
/** | ||
* Determines whether or not `.getBoundingClientRect()` is affected by visual | ||
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the | ||
* visual viewport, while in other engines, they are values relative to the | ||
* layout viewport. | ||
*/ | ||
function isClientRectVisualViewportBased() { | ||
// 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> | ||
// Is Safari. | ||
return /^((?!chrome|android).)*safari/i.test(getUAString()); | ||
function isSafari() { | ||
if (typeof CSS === 'undefined' || !CSS.supports) return false; | ||
return CSS.supports('-webkit-backdrop-filter', 'none'); | ||
} | ||
@@ -158,4 +124,25 @@ function isLastTraversableNode(node) { | ||
const noOffsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
function getVisualOffsets(element, isFixed, floatingOffsetParent) { | ||
var _win$visualViewport, _win$visualViewport2; | ||
if (isFixed === void 0) { | ||
isFixed = true; | ||
} | ||
if (!isSafari()) { | ||
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 | ||
}; | ||
} | ||
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { | ||
var _win$visualViewport, _win$visualViewport2; | ||
if (includeScale === void 0) { | ||
@@ -179,6 +166,5 @@ includeScale = false; | ||
} | ||
const win = domElement ? getWindow(domElement) : window; | ||
const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy; | ||
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x; | ||
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y; | ||
const visualOffsets = getVisualOffsets(domElement, isFixedStrategy, offsetParent); | ||
let x = (clientRect.left + visualOffsets.x) / scale.x; | ||
let y = (clientRect.top + visualOffsets.y) / scale.y; | ||
let width = clientRect.width / scale.x; | ||
@@ -353,3 +339,3 @@ let height = clientRect.height / scale.y; | ||
height = visualViewport.height; | ||
const visualViewportBased = isClientRectVisualViewportBased(); | ||
const visualViewportBased = isSafari(); | ||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') { | ||
@@ -397,12 +383,8 @@ x = visualViewport.offsetLeft; | ||
} else { | ||
const mutableRect = { | ||
...clippingAncestor | ||
const visualOffsets = getVisualOffsets(element); | ||
rect = { | ||
...clippingAncestor, | ||
x: clippingAncestor.x - visualOffsets.x, | ||
y: clippingAncestor.y - visualOffsets.y | ||
}; | ||
if (isClientRectVisualViewportBased()) { | ||
var _win$visualViewport, _win$visualViewport2; | ||
const win = getWindow(element); | ||
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0; | ||
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0; | ||
} | ||
rect = mutableRect; | ||
} | ||
@@ -526,3 +508,4 @@ return rectToClientRect(rect); | ||
const documentElement = getDocumentElement(offsetParent); | ||
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent); | ||
const isFixed = strategy === 'fixed'; | ||
const rect = getBoundingClientRect(element, true, isFixed, offsetParent); | ||
let scroll = { | ||
@@ -536,3 +519,3 @@ scrollLeft: 0, | ||
}; | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') { | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { | ||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { | ||
@@ -542,3 +525,3 @@ scroll = getNodeScroll(offsetParent); | ||
if (isHTMLElement(offsetParent)) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); | ||
offsets.x = offsetRect.x + offsetParent.clientLeft; | ||
@@ -545,0 +528,0 @@ offsets.y = offsetRect.y + offsetParent.clientTop; |
@@ -23,15 +23,2 @@ (function (global, factory) { | ||
let uaString; | ||
function getUAString() { | ||
if (uaString) { | ||
return uaString; | ||
} | ||
const uaData = navigator.userAgentData; | ||
if (uaData && Array.isArray(uaData.brands)) { | ||
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' '); | ||
return uaString; | ||
} | ||
return navigator.userAgent; | ||
} | ||
function isHTMLElement(value) { | ||
@@ -64,32 +51,11 @@ return value instanceof getWindow(value).HTMLElement; | ||
function isContainingBlock(element) { | ||
// TODO: Try to use feature detection here instead. | ||
const isFirefox = /firefox/i.test(getUAString()); | ||
const safari = isSafari(); | ||
const css = getComputedStyle$1(element); | ||
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter; | ||
// 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 | ||
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; | ||
return contain != null ? contain.includes(value) : false; | ||
}); | ||
return css.transform !== 'none' || css.perspective !== 'none' || !safari && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !safari && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value)); | ||
} | ||
/** | ||
* Determines whether or not `.getBoundingClientRect()` is affected by visual | ||
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the | ||
* visual viewport, while in other engines, they are values relative to the | ||
* layout viewport. | ||
*/ | ||
function isClientRectVisualViewportBased() { | ||
// 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> | ||
// Is Safari. | ||
return /^((?!chrome|android).)*safari/i.test(getUAString()); | ||
function isSafari() { | ||
if (typeof CSS === 'undefined' || !CSS.supports) return false; | ||
return CSS.supports('-webkit-backdrop-filter', 'none'); | ||
} | ||
@@ -161,4 +127,25 @@ function isLastTraversableNode(node) { | ||
const noOffsets = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
function getVisualOffsets(element, isFixed, floatingOffsetParent) { | ||
var _win$visualViewport, _win$visualViewport2; | ||
if (isFixed === void 0) { | ||
isFixed = true; | ||
} | ||
if (!isSafari()) { | ||
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 | ||
}; | ||
} | ||
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { | ||
var _win$visualViewport, _win$visualViewport2; | ||
if (includeScale === void 0) { | ||
@@ -182,6 +169,5 @@ includeScale = false; | ||
} | ||
const win = domElement ? getWindow(domElement) : window; | ||
const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy; | ||
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x; | ||
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y; | ||
const visualOffsets = getVisualOffsets(domElement, isFixedStrategy, offsetParent); | ||
let x = (clientRect.left + visualOffsets.x) / scale.x; | ||
let y = (clientRect.top + visualOffsets.y) / scale.y; | ||
let width = clientRect.width / scale.x; | ||
@@ -356,3 +342,3 @@ let height = clientRect.height / scale.y; | ||
height = visualViewport.height; | ||
const visualViewportBased = isClientRectVisualViewportBased(); | ||
const visualViewportBased = isSafari(); | ||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') { | ||
@@ -400,12 +386,8 @@ x = visualViewport.offsetLeft; | ||
} else { | ||
const mutableRect = { | ||
...clippingAncestor | ||
const visualOffsets = getVisualOffsets(element); | ||
rect = { | ||
...clippingAncestor, | ||
x: clippingAncestor.x - visualOffsets.x, | ||
y: clippingAncestor.y - visualOffsets.y | ||
}; | ||
if (isClientRectVisualViewportBased()) { | ||
var _win$visualViewport, _win$visualViewport2; | ||
const win = getWindow(element); | ||
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0; | ||
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0; | ||
} | ||
rect = mutableRect; | ||
} | ||
@@ -529,3 +511,4 @@ return core.rectToClientRect(rect); | ||
const documentElement = getDocumentElement(offsetParent); | ||
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent); | ||
const isFixed = strategy === 'fixed'; | ||
const rect = getBoundingClientRect(element, true, isFixed, offsetParent); | ||
let scroll = { | ||
@@ -539,3 +522,3 @@ scrollLeft: 0, | ||
}; | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') { | ||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { | ||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { | ||
@@ -545,3 +528,3 @@ scroll = getNodeScroll(offsetParent); | ||
if (isHTMLElement(offsetParent)) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); | ||
offsets.x = offsetRect.x + offsetParent.clientLeft; | ||
@@ -548,0 +531,0 @@ offsets.y = offsetRect.y + offsetParent.clientTop; |
@@ -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():""}let l;function c(){if(l)return l;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(l=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),l):navigator.userAgent}function f(t){return t instanceof n(t).HTMLElement}function s(t){return t instanceof n(t).Element}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(r(t))}function h(t){const e=/firefox/i.test(c()),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(c())}function g(t){return["html","body","#document"].includes(r(t))}const m=Math.min,y=Math.max,x=Math.round;function w(t){const e=o(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=f(t),l=r?t.offsetWidth:n,c=r?t.offsetHeight:i,s=x(n)!==l||x(i)!==c;return s&&(n=l,i=c),{width:n,height:i,fallback:s}}function b(t){return s(t)?t:t.contextElement}const v={x:1,y:1};function L(t){const e=b(t);if(!f(e))return v;const n=e.getBoundingClientRect(),{width:o,height:i,fallback:r}=w(e);let l=(r?x(n.width):n.width)/o,c=(r?x(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),c&&Number.isFinite(c)||(c=1),{x:l,y:c}}function T(t,o,i,r){var l,c;void 0===o&&(o=!1),void 0===i&&(i=!1);const f=t.getBoundingClientRect(),u=b(t);let a=v;o&&(r?s(r)&&(a=L(r)):a=L(t));const d=u?n(u):window,h=p()&&i;let g=(f.left+(h&&(null==(l=d.visualViewport)?void 0:l.offsetLeft)||0))/a.x,m=(f.top+(h&&(null==(c=d.visualViewport)?void 0:c.offsetTop)||0))/a.y,y=f.width/a.x,x=f.height/a.y;if(u){const t=n(u),e=r&&s(r)?n(r):r;let o=t.frameElement;for(;o&&r&&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,g*=t.x,m*=t.y,y*=t.x,x*=t.y,g+=e.x,m+=e.y,o=n(o).frameElement}}return e.rectToClientRect({width:y,height:x,x:g,y:m})}function O(t){return((i(t)?t.ownerDocument:t.document)||window.document).documentElement}function P(t){return s(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){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||u(t)&&t.host||O(t);return u(e)?e.host:e}function C(t){const e=E(t);return g(e)?e.ownerDocument.body:f(e)&&a(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||[],a(i)?i:[]):e.concat(i,j(i))}function F(t,i,r){let l;if("viewport"===i)l=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);else if("document"===i)l=function(t){const e=O(t),n=P(t),i=t.ownerDocument.body,r=y(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),l=y(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let c=-n.scrollLeft+R(t);const f=-n.scrollTop;return"rtl"===o(i).direction&&(c+=y(e.clientWidth,i.clientWidth)-r),{width:r,height:l,x:c,y:f}}(O(t));else if(s(i))l=function(t,e){const n=T(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=f(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,r);else{const e={...i};if(p()){var c,u;const o=n(t);e.x-=(null==(c=o.visualViewport)?void 0:c.offsetLeft)||0,e.y-=(null==(u=o.visualViewport)?void 0:u.offsetTop)||0}l=e}return e.rectToClientRect(l)}function S(t,e){const n=E(t);return!(n===e||!s(n)||g(n))&&("fixed"===o(n).position||S(n,e))}function D(t,e){return f(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function W(t,e){const i=n(t);if(!f(t))return i;let l=D(t,e);for(;l&&d(l)&&"static"===o(l).position;)l=D(l,e);return l&&("html"===r(l)||"body"===r(l)&&"static"===o(l).position&&!h(l))?i:l||function(t){let e=E(t);for(;f(e)&&!g(e);){if(h(e))return e;e=E(e)}return null}(t)||i}function A(t,e,n){const o=f(e),i=O(e),l=T(t,!0,"fixed"===n,e);let c={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==r(e)||a(i))&&(c=P(e)),f(e)){const t=T(e,!0);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else i&&(s.x=R(i));return{x:l.left+c.scrollLeft-s.x,y:l.top+c.scrollTop-s.y,width:l.width,height:l.height}}const V={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:i,strategy:l}=t;const c="clippingAncestors"===n?function(t,e){const n=e.get(t);if(n)return n;let i=j(t).filter((t=>s(t)&&"body"!==r(t))),l=null;const c="fixed"===o(t).position;let f=c?E(t):t;for(;s(f)&&!g(f);){const e=o(f),n=h(f);n||"fixed"!==e.position||(l=null),(c?!n&&!l:!n&&"static"===e.position&&l&&["absolute","fixed"].includes(l.position)||a(f)&&!n&&S(t,f))?i=i.filter((t=>t!==f)):l=e,f=E(f)}return e.set(t,i),i}(e,this._c):[].concat(n),f=[...c,i],u=f[0],d=f.reduce(((t,n)=>{const o=F(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}),F(e,u,l));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=f(n),l=O(n);if(n===l)return e;let c={scrollLeft:0,scrollTop:0},s={x:1,y:1};const u={x:0,y:0};if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||a(l))&&(c=P(n)),f(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-c.scrollLeft*s.x+u.x,y:e.y*s.y-c.scrollTop*s.y+u.y}},isElement:s,getDimensions:function(t){return w(t)},getOffsetParent:W,getDocumentElement:O,getScale:L,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||W,r=this.getDimensions;return{reference:A(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||r?[...s(t)?j(t):t.contextElement?j(t.contextElement):[],...j(e)]:[];f.forEach((t=>{const e=!s(t)&&t.toString().includes("V");!i||c&&!e||t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));let u,a=null;l&&(a=new ResizeObserver((()=>{n()})),s(t)&&!c&&a.observe(t),s(t)||!t.contextElement||c||a.observe(t.contextElement),a.observe(e));let d=c?T(t):null;return c&&function e(){const o=T(t);!d||o.x===d.x&&o.y===d.y&&o.width===d.width&&o.height===d.height||n();d=o,u=requestAnimationFrame(e)}(),n(),()=>{var t;f.forEach((t=>{i&&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:V,...o},l={...r.platform,_c:i};return e.computePosition(t,n,{...r,platform:l})},t.getOverflowAncestors=j,t.platform=V,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@floating-ui/core")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM={},t.FloatingUICore)}(this,(function(t,e){"use strict";function n(t){var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i(t){return t instanceof n(t).Node}function r(t){return i(t)?(t.nodeName||"").toLowerCase():""}function c(t){return t instanceof n(t).HTMLElement}function l(t){return t instanceof n(t).Element}function f(t){if("undefined"==typeof ShadowRoot)return!1;return 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||!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,g=Math.max,m=Math.round;function y(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,fallback:s}}function x(t){return l(t)?t:t.contextElement}const w={x:1,y:1};function b(t){const e=x(t);if(!c(e))return w;const n=e.getBoundingClientRect(),{width:o,height:i,fallback:r}=y(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 v={x:0,y:0};function L(t,e,o){var i,r;if(void 0===e&&(e=!0),!a())return v;const c=t?n(t):window;return!o||e&&o!==c?v:{x:(null==(i=c.visualViewport)?void 0:i.offsetLeft)||0,y:(null==(r=c.visualViewport)?void 0:r.offsetTop)||0}}function T(t,o,i,r){void 0===o&&(o=!1),void 0===i&&(i=!1);const c=t.getBoundingClientRect(),f=x(t);let s=w;o&&(r?l(r)&&(s=b(r)):s=b(t));const u=L(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=b(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,d*=t.x,a*=t.y,h*=t.x,p*=t.y,d+=e.x,a+=e.y,o=n(o).frameElement}}return e.rectToClientRect({width:h,height:p,x:d,y:a})}function O(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 R(t){return T(O(t)).left+P(t).scrollLeft}function E(t){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||f(t)&&t.host||O(t);return f(e)?e.host:e}function S(t){const e=E(t);return h(e)?e.ownerDocument.body:c(e)&&s(e)?e:S(e)}function C(t,e){var o;void 0===e&&(e=[]);const i=S(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,C(i))}function F(t,i,r){let f;if("viewport"===i)f=function(t,e){const o=n(t),i=O(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=O(t),n=P(t),i=t.ownerDocument.body,r=g(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),c=g(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-n.scrollLeft+R(t);const f=-n.scrollTop;return"rtl"===o(i).direction&&(l+=g(e.clientWidth,i.clientWidth)-r),{width:r,height:c,x:l,y:f}}(O(t));else if(l(i))f=function(t,e){const n=T(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=c(t)?b(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,r);else{const e=L(t);f={...i,x:i.x-e.x,y:i.y-e.y}}return e.rectToClientRect(f)}function j(t,e){const n=E(t);return!(n===e||!l(n)||h(n))&&("fixed"===o(n).position||j(n,e))}function D(t,e){return c(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function W(t,e){const i=n(t);if(!c(t))return i;let l=D(t,e);for(;l&&u(l)&&"static"===o(l).position;)l=D(l,e);return l&&("html"===r(l)||"body"===r(l)&&"static"===o(l).position&&!d(l))?i:l||function(t){let e=E(t);for(;c(e)&&!h(e);){if(d(e))return e;e=E(e)}return null}(t)||i}function H(t,e,n){const o=c(e),i=O(e),l="fixed"===n,f=T(t,!0,l,e);let u={scrollLeft:0,scrollTop:0};const d={x:0,y:0};if(o||!o&&!l)if(("body"!==r(e)||s(i))&&(u=P(e)),c(e)){const t=T(e,!0,l,e);d.x=t.x+e.clientLeft,d.y=t.y+e.clientTop}else i&&(d.x=R(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=C(t).filter((t=>l(t)&&"body"!==r(t))),c=null;const f="fixed"===o(t).position;let u=f?E(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&&j(t,u))?i=i.filter((t=>t!==u)):c=e,u=E(u)}return e.set(t,i),i}(e,this._c):[].concat(n),u=[...f,i],a=u[0],m=u.reduce(((t,n)=>{const o=F(e,n,c);return t.top=g(o.top,t.top),t.right=p(o.right,t.right),t.bottom=p(o.bottom,t.bottom),t.left=g(o.left,t.left),t}),F(e,a,c));return{width:m.right-m.left,height:m.bottom-m.top,x:m.left,y:m.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=c(n),l=O(n);if(n===l)return e;let f={scrollLeft:0,scrollTop:0},u={x:1,y:1};const d={x:0,y:0};if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||s(l))&&(f=P(n)),c(n))){const t=T(n);u=b(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 y(t)},getOffsetParent:W,getDocumentElement:O,getScale:b,async getElementRects(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||W,r=this.getDimensions;return{reference:H(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=!0,animationFrame:f=!1}=o,s=i||r?[...l(t)?C(t):t.contextElement?C(t.contextElement):[],...C(e)]:[];s.forEach((t=>{const e=!l(t)&&t.toString().includes("V");!i||f&&!e||t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));let u,d=null;c&&(d=new ResizeObserver((()=>{n()})),l(t)&&!f&&d.observe(t),l(t)||!t.contextElement||f||d.observe(t.contextElement),d.observe(e));let a=f?T(t):null;return f&&function e(){const o=T(t);!a||o.x===a.x&&o.y===a.y&&o.width===a.width&&o.height===a.height||n();a=o,u=requestAnimationFrame(e)}(),n(),()=>{var t;s.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==(t=d)||t.disconnect(),d=null,f&&cancelAnimationFrame(u)}},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=C,t.platform=z,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/dom", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"@rollingversions": { | ||
@@ -5,0 +5,0 @@ "baseVersion": [ |
@@ -15,9 +15,3 @@ declare global { | ||
export declare function isContainingBlock(element: Element): boolean; | ||
/** | ||
* Determines whether or not `.getBoundingClientRect()` is affected by visual | ||
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the | ||
* visual viewport, while in other engines, they are values relative to the | ||
* layout viewport. | ||
*/ | ||
export declare function isClientRectVisualViewportBased(): boolean; | ||
export declare function isSafari(): boolean; | ||
export declare function isLastTraversableNode(node: Node): boolean; |
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
123248
2868