@floating-ui/dom
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -96,5 +96,12 @@ import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core'; | ||
} | ||
function isLayoutViewport() { | ||
/** | ||
* 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: | ||
// this can fail in various ways, making the userAgent check the most | ||
// reliable: | ||
@@ -104,4 +111,4 @@ // • Always-visible scrollbar or not | ||
// Not Safari. | ||
return !/^((?!chrome|android).)*safari/i.test(getUAString()); | ||
// Is Safari. | ||
return /^((?!chrome|android).)*safari/i.test(getUAString()); | ||
} | ||
@@ -169,3 +176,3 @@ function isLastTraversableNode(node) { | ||
const win = domElement ? getWindow(domElement) : window; | ||
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy; | ||
const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy; | ||
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x; | ||
@@ -346,4 +353,4 @@ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y; | ||
height = visualViewport.height; | ||
const layoutViewport = isLayoutViewport(); | ||
if (layoutViewport || !layoutViewport && strategy === 'fixed') { | ||
const visualViewportBased = isClientRectVisualViewportBased(); | ||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') { | ||
x = visualViewport.offsetLeft; | ||
@@ -382,9 +389,22 @@ y = visualViewport.offsetTop; | ||
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { | ||
let rect; | ||
if (clippingAncestor === 'viewport') { | ||
return rectToClientRect(getViewportRect(element, strategy)); | ||
rect = getViewportRect(element, strategy); | ||
} else if (clippingAncestor === 'document') { | ||
rect = getDocumentRect(getDocumentElement(element)); | ||
} else if (isElement(clippingAncestor)) { | ||
rect = getInnerBoundingClientRect(clippingAncestor, strategy); | ||
} else { | ||
const mutableRect = { | ||
...clippingAncestor | ||
}; | ||
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; | ||
} | ||
if (isElement(clippingAncestor)) { | ||
return rectToClientRect(getInnerBoundingClientRect(clippingAncestor, strategy)); | ||
} | ||
return rectToClientRect(getDocumentRect(getDocumentElement(element))); | ||
return rectToClientRect(rect); | ||
} | ||
@@ -458,6 +478,9 @@ | ||
function getTrueOffsetParent(element) { | ||
function getTrueOffsetParent(element, polyfill) { | ||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') { | ||
return null; | ||
} | ||
if (polyfill) { | ||
return polyfill(element); | ||
} | ||
return element.offsetParent; | ||
@@ -479,7 +502,7 @@ } | ||
// such as table ancestors and cross browser bugs. | ||
function getOffsetParent(element) { | ||
function getOffsetParent(element, polyfill) { | ||
const window = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
let offsetParent = getTrueOffsetParent(element, polyfill); | ||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
offsetParent = getTrueOffsetParent(offsetParent, polyfill); | ||
} | ||
@@ -486,0 +509,0 @@ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) { |
@@ -99,5 +99,12 @@ (function (global, factory) { | ||
} | ||
function isLayoutViewport() { | ||
/** | ||
* 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: | ||
// this can fail in various ways, making the userAgent check the most | ||
// reliable: | ||
@@ -107,4 +114,4 @@ // • Always-visible scrollbar or not | ||
// Not Safari. | ||
return !/^((?!chrome|android).)*safari/i.test(getUAString()); | ||
// Is Safari. | ||
return /^((?!chrome|android).)*safari/i.test(getUAString()); | ||
} | ||
@@ -172,3 +179,3 @@ function isLastTraversableNode(node) { | ||
const win = domElement ? getWindow(domElement) : window; | ||
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy; | ||
const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy; | ||
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x; | ||
@@ -349,4 +356,4 @@ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y; | ||
height = visualViewport.height; | ||
const layoutViewport = isLayoutViewport(); | ||
if (layoutViewport || !layoutViewport && strategy === 'fixed') { | ||
const visualViewportBased = isClientRectVisualViewportBased(); | ||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') { | ||
x = visualViewport.offsetLeft; | ||
@@ -385,9 +392,22 @@ y = visualViewport.offsetTop; | ||
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { | ||
let rect; | ||
if (clippingAncestor === 'viewport') { | ||
return core.rectToClientRect(getViewportRect(element, strategy)); | ||
rect = getViewportRect(element, strategy); | ||
} else if (clippingAncestor === 'document') { | ||
rect = getDocumentRect(getDocumentElement(element)); | ||
} else if (isElement(clippingAncestor)) { | ||
rect = getInnerBoundingClientRect(clippingAncestor, strategy); | ||
} else { | ||
const mutableRect = { | ||
...clippingAncestor | ||
}; | ||
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; | ||
} | ||
if (isElement(clippingAncestor)) { | ||
return core.rectToClientRect(getInnerBoundingClientRect(clippingAncestor, strategy)); | ||
} | ||
return core.rectToClientRect(getDocumentRect(getDocumentElement(element))); | ||
return core.rectToClientRect(rect); | ||
} | ||
@@ -461,6 +481,9 @@ | ||
function getTrueOffsetParent(element) { | ||
function getTrueOffsetParent(element, polyfill) { | ||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') { | ||
return null; | ||
} | ||
if (polyfill) { | ||
return polyfill(element); | ||
} | ||
return element.offsetParent; | ||
@@ -482,7 +505,7 @@ } | ||
// such as table ancestors and cross browser bugs. | ||
function getOffsetParent(element) { | ||
function getOffsetParent(element, polyfill) { | ||
const window = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
let offsetParent = getTrueOffsetParent(element, polyfill); | ||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
offsetParent = getTrueOffsetParent(offsetParent, polyfill); | ||
} | ||
@@ -489,0 +512,0 @@ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) { |
@@ -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)}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})})); | ||
!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 O(t){return((h(t)?t.ownerDocument:t.document)||window.document).documentElement}function P(t){return d(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"===f(t))return t;const e=t.assignedSlot||t.parentNode||p(t)&&t.host||O(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){let c;if("viewport"===i)c=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=w();(!t||t&&"fixed"===e)&&(f=r.offsetLeft,s=r.offsetTop)}return{width:l,height:c,x:f,y:s}}(t,l);else if("document"===i)c=function(t){const e=O(t),n=P(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+R(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}}(O(t));else if(d(i))c=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);else{const e={...i};if(w()){var f,s;const o=n(t);e.x-=(null==(f=o.visualViewport)?void 0:f.offsetLeft)||0,e.y-=(null==(s=o.visualViewport)?void 0:s.offsetTop)||0}c=e}return e.rectToClientRect(c)}function D(t,e){return a(t)&&"fixed"!==o(t).position?e?e(t):t.offsetParent:null}function S(t,e){const i=n(t);let r=D(t,e);for(;r&&m(r)&&"static"===o(r).position;)r=D(r,e);return r&&("html"===f(r)||"body"===f(r)&&"static"===o(r).position&&!y(r))?i:r||function(t){let e=E(t);for(;a(e)&&!x(e);){if(y(e))return e;e=E(e)}return null}(t)||i}function W(t,e,n){const o=a(e),i=O(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=P(e)),a(e)){const t=T(e,!0);c.x=t.x+e.clientLeft,c.y=t.y+e.clientTop}else i&&(c.x=R(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=O(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=P(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:O,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.1", | ||
"version": "1.2.0", | ||
"@rollingversions": { | ||
@@ -63,3 +63,3 @@ "baseVersion": [ | ||
"dependencies": { | ||
"@floating-ui/core": "^1.1.0" | ||
"@floating-ui/core": "^1.2.0" | ||
}, | ||
@@ -66,0 +66,0 @@ "devDependencies": { |
import type { Platform } from './types'; | ||
export declare const platform: Platform; | ||
export declare const platform: Required<Platform>; |
@@ -21,3 +21,3 @@ 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'; | ||
}) => Promisable<Rect>; | ||
getOffsetParent?: (element: Element) => Promisable<Element | Window>; | ||
getOffsetParent?: (element: Element, polyfill?: (element: HTMLElement) => Element | null) => Promisable<Element | Window>; | ||
isElement?: (value: unknown) => Promisable<boolean>; | ||
@@ -36,3 +36,3 @@ getDocumentElement?: (element: Element) => Promisable<HTMLElement>; | ||
} | ||
export type Boundary = 'clippingAncestors' | Element | Array<Element>; | ||
export type Boundary = 'clippingAncestors' | Element | Array<Element> | Rect; | ||
export type DetectOverflowOptions = Omit<CoreDetectOverflowOptions, 'boundary'> & { | ||
@@ -39,0 +39,0 @@ boundary: Boundary; |
@@ -1,1 +0,3 @@ | ||
export declare function getOffsetParent(element: Element): Element | Window; | ||
type Polyfill = (element: HTMLElement) => Element | null; | ||
export declare function getOffsetParent(element: Element, polyfill?: Polyfill): Element | Window; | ||
export {}; |
@@ -16,3 +16,9 @@ declare global { | ||
export declare function isContainingBlock(element: Element): boolean; | ||
export declare function isLayoutViewport(): 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 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
122967
2865
Updated@floating-ui/core@^1.2.0