123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- import {
- rectToClientRect
- } from "./chunk-LPWNO2ZS.js";
- import "./chunk-2TTT3V5O.js";
- import "./chunk-IOZKU7B2.js";
- import "./chunk-S5KM4IGW.js";
- // node_modules/@esri/calcite-components/dist/components/nonChromiumPlatformUtils.js
- function getTrueOffsetParent(element) {
- if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
- return null;
- }
- return composedOffsetParent(element);
- }
- function composedOffsetParent(element) {
- let { offsetParent } = element;
- let ancestor = element;
- let foundInsideSlot = false;
- while (ancestor && ancestor !== offsetParent) {
- const { assignedSlot } = ancestor;
- if (assignedSlot) {
- let newOffsetParent = assignedSlot.offsetParent;
- if (getComputedStyle(assignedSlot).display === "contents") {
- const hadStyleAttribute = assignedSlot.hasAttribute("style");
- const oldDisplay = assignedSlot.style.display;
- assignedSlot.style.display = getComputedStyle(ancestor).display;
- newOffsetParent = assignedSlot.offsetParent;
- assignedSlot.style.display = oldDisplay;
- if (!hadStyleAttribute) {
- assignedSlot.removeAttribute("style");
- }
- }
- ancestor = assignedSlot;
- if (offsetParent !== newOffsetParent) {
- offsetParent = newOffsetParent;
- foundInsideSlot = true;
- }
- } else if (isShadowRoot(ancestor) && ancestor.host && foundInsideSlot) {
- break;
- }
- ancestor = isShadowRoot(ancestor) && ancestor.host || ancestor.parentNode;
- }
- return offsetParent;
- }
- function getElementRects(_ref) {
- const { reference, floating, strategy } = _ref;
- return {
- reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
- floating: { ...getDimensions(floating), x: 0, y: 0 }
- };
- }
- function isWindow(value) {
- return value && value.document && value.location && value.alert && value.setInterval;
- }
- function getWindow(node) {
- if (node == null) {
- return window;
- }
- if (!isWindow(node)) {
- const ownerDocument = node.ownerDocument;
- return ownerDocument ? ownerDocument.defaultView || window : window;
- }
- return node;
- }
- function getComputedStyle(element) {
- return getWindow(element).getComputedStyle(element);
- }
- function getNodeName(node) {
- return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
- }
- function getUAString() {
- const uaData = navigator.userAgentData;
- if (uaData != null && uaData.brands) {
- return uaData.brands.map((item) => item.brand + "/" + item.version).join(" ");
- }
- return navigator.userAgent;
- }
- function isHTMLElement(value) {
- return value instanceof getWindow(value).HTMLElement;
- }
- function isElement(value) {
- return value instanceof getWindow(value).Element;
- }
- function isNode(value) {
- return value instanceof getWindow(value).Node;
- }
- function isShadowRoot(node) {
- if (typeof ShadowRoot === "undefined") {
- return false;
- }
- const OwnElement = getWindow(node).ShadowRoot;
- return node instanceof OwnElement || node instanceof ShadowRoot;
- }
- function isOverflowElement(element) {
- const { overflow, overflowX, overflowY, display } = getComputedStyle(element);
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
- }
- function isTableElement(element) {
- return ["table", "td", "th"].includes(getNodeName(element));
- }
- function isContainingBlock(element) {
- const isFirefox = /firefox/i.test(getUAString());
- const css = getComputedStyle(element);
- return css.transform !== "none" || css.perspective !== "none" || 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) => {
- const contain = css.contain;
- return contain != null ? contain.includes(value) : false;
- }
- );
- }
- function isLayoutViewport() {
- return !/^((?!chrome|android).)*safari/i.test(getUAString());
- }
- function isLastTraversableNode(node) {
- return ["html", "body", "#document"].includes(getNodeName(node));
- }
- var min = Math.min;
- var max = Math.max;
- var round = Math.round;
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
- var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
- if (includeScale === void 0) {
- includeScale = false;
- }
- if (isFixedStrategy === void 0) {
- isFixedStrategy = false;
- }
- const clientRect = element.getBoundingClientRect();
- let scaleX = 1;
- let scaleY = 1;
- if (includeScale && isHTMLElement(element)) {
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
- }
- const win = isElement(element) ? getWindow(element) : window;
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
- const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
- const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
- const width = clientRect.width / scaleX;
- const height = clientRect.height / scaleY;
- return {
- width,
- height,
- top: y,
- right: x + width,
- bottom: y + height,
- left: x,
- x,
- y
- };
- }
- function getDocumentElement(node) {
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
- }
- function getNodeScroll(element) {
- if (isElement(element)) {
- return {
- scrollLeft: element.scrollLeft,
- scrollTop: element.scrollTop
- };
- }
- return {
- scrollLeft: element.pageXOffset,
- scrollTop: element.pageYOffset
- };
- }
- function getWindowScrollBarX(element) {
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
- }
- function isScaled(element) {
- const rect = getBoundingClientRect(element);
- return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
- }
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
- const documentElement = getDocumentElement(offsetParent);
- const rect = getBoundingClientRect(
- element,
- isOffsetParentAnElement && isScaled(offsetParent),
- strategy === "fixed"
- );
- 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;
- }
- return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
- }
- function getContainingBlock(element) {
- let currentNode = getParentNode(element);
- if (isShadowRoot(currentNode)) {
- currentNode = currentNode.host;
- }
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
- if (isContainingBlock(currentNode)) {
- return currentNode;
- } else {
- const parent = currentNode.parentNode;
- currentNode = isShadowRoot(parent) ? parent.host : parent;
- }
- }
- return null;
- }
- function getOffsetParent(element) {
- const window2 = getWindow(element);
- let offsetParent = getTrueOffsetParent(element);
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
- offsetParent = getTrueOffsetParent(offsetParent);
- }
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
- return window2;
- }
- return offsetParent || getContainingBlock(element) || window2;
- }
- function getDimensions(element) {
- if (isHTMLElement(element)) {
- return {
- width: element.offsetWidth,
- height: element.offsetHeight
- };
- }
- const rect = getBoundingClientRect(element);
- return {
- width: rect.width,
- height: rect.height
- };
- }
- 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 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);
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
- const y = -scroll.scrollTop;
- if (getComputedStyle(body || html).direction === "rtl") {
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
- }
- return {
- width,
- height,
- x,
- y
- };
- }
- function getNearestOverflowAncestor(node) {
- const parentNode = getParentNode(node);
- if (isLastTraversableNode(parentNode)) {
- return node.ownerDocument.body;
- }
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
- return parentNode;
- }
- return getNearestOverflowAncestor(parentNode);
- }
- function getOverflowAncestors(node, list) {
- var _node$ownerDocument;
- if (list === void 0) {
- list = [];
- }
- const scrollableAncestor = getNearestOverflowAncestor(node);
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
- const win = getWindow(scrollableAncestor);
- const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
- const updatedList = list.concat(target);
- return isBody ? updatedList : updatedList.concat(getOverflowAncestors(target));
- }
- function contains(parent, child) {
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
- if (parent.contains(child)) {
- return true;
- } else if (rootNode && isShadowRoot(rootNode)) {
- let next = child;
- do {
- if (next && parent === next) {
- return true;
- }
- next = next.parentNode || next.host;
- } while (next);
- }
- return false;
- }
- function getNearestParentCapableOfEscapingClipping(element, clippingAncestors) {
- let currentNode = element;
- while (currentNode && !isLastTraversableNode(currentNode) && !clippingAncestors.includes(currentNode)) {
- if (isElement(currentNode) && ["absolute", "fixed"].includes(getComputedStyle(currentNode).position)) {
- break;
- }
- const parentNode = getParentNode(currentNode);
- currentNode = isShadowRoot(parentNode) ? parentNode.host : parentNode;
- }
- return currentNode;
- }
- function getInnerBoundingClientRect(element, strategy) {
- const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
- const top = clientRect.top + element.clientTop;
- const left = clientRect.left + element.clientLeft;
- return {
- top,
- left,
- x: left,
- y: top,
- right: left + element.clientWidth,
- bottom: top + element.clientHeight,
- width: element.clientWidth,
- height: element.clientHeight
- };
- }
- function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
- if (clippingParent === "viewport") {
- return rectToClientRect(getViewportRect(element, strategy));
- }
- if (isElement(clippingParent)) {
- return getInnerBoundingClientRect(clippingParent, strategy);
- }
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
- }
- function getClippingAncestors(element) {
- const clippingAncestors = getOverflowAncestors(element);
- const nearestEscapableParent = getNearestParentCapableOfEscapingClipping(element, clippingAncestors);
- let clipperElement = null;
- if (nearestEscapableParent && isHTMLElement(nearestEscapableParent)) {
- const offsetParent = getOffsetParent(nearestEscapableParent);
- if (isOverflowElement(nearestEscapableParent)) {
- clipperElement = nearestEscapableParent;
- } else if (isHTMLElement(offsetParent)) {
- clipperElement = offsetParent;
- }
- }
- if (!isElement(clipperElement)) {
- return [];
- }
- return clippingAncestors.filter((clippingAncestors2) => clipperElement && isElement(clippingAncestors2) && contains(clippingAncestors2, clipperElement) && getNodeName(clippingAncestors2) !== "body");
- }
- function getClippingRect(_ref) {
- let { element, boundary, rootBoundary, strategy } = _ref;
- const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
- const clippingAncestors = [...mainClippingAncestors, rootBoundary];
- const firstClippingAncestor = clippingAncestors[0];
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
- accRect.top = max(rect.top, accRect.top);
- accRect.right = min(rect.right, accRect.right);
- accRect.bottom = min(rect.bottom, accRect.bottom);
- accRect.left = max(rect.left, accRect.left);
- return accRect;
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
- return {
- width: clippingRect.right - clippingRect.left,
- height: clippingRect.bottom - clippingRect.top,
- x: clippingRect.left,
- y: clippingRect.top
- };
- }
- export {
- getClippingRect,
- getElementRects,
- getOffsetParent
- };
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- //# sourceMappingURL=nonChromiumPlatformUtils-WEX4VIW3.js.map
|