@carbon/ibm-products 2.71.0 → 2.72.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/carbon.css +50 -0
- package/css/carbon.css.map +1 -1
- package/css/index-full-carbon.css +560 -185
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +132 -1
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +570 -245
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +358 -33
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/{BigNumbers/BigNumbers.d.ts → BigNumber/BigNumber.d.ts} +5 -5
- package/es/components/{BigNumbers/BigNumbers.js → BigNumber/BigNumber.js} +12 -12
- package/es/components/BigNumber/BigNumberSkeleton.d.ts +17 -0
- package/es/components/{BigNumbers/BigNumbersSkeleton.js → BigNumber/BigNumberSkeleton.js} +16 -16
- package/es/components/{BigNumbers → BigNumber}/constants.d.ts +3 -3
- package/es/components/{BigNumbers → BigNumber}/constants.js +6 -6
- package/es/components/{BigNumbers → BigNumber}/index.d.ts +2 -2
- package/es/components/Coachmark/next/Coachmark/Coachmark.d.ts +72 -0
- package/es/components/Coachmark/next/Coachmark/Coachmark.js +185 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBeacon/CoachmarkBeacon.d.ts +44 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBeacon/index.d.ts +8 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.d.ts +38 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +125 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.d.ts +24 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.js +25 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/index.d.ts +10 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkContent.d.ts +34 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkContent.js +118 -0
- package/es/components/Coachmark/next/Coachmark/ContentBody.d.ts +23 -0
- package/es/components/Coachmark/next/Coachmark/ContentBody.js +37 -0
- package/es/components/Coachmark/next/Coachmark/ContentHeader.d.ts +21 -0
- package/es/components/Coachmark/next/Coachmark/ContentHeader.js +89 -0
- package/{lib/components/BigNumbers → es/components/Coachmark/next/Coachmark}/index.d.ts +2 -2
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +0 -1
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -5
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +11 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +1 -1
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +42 -3
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +5 -3
- package/es/components/ConditionBuilder/utils/useTranslations.js +1 -1
- package/es/components/EditInPlace/EditInPlace.js +0 -3
- package/es/components/EmptyStates/EmptyState.d.ts +2 -2
- package/es/components/EmptyStates/EmptyState.js +2 -8
- package/es/components/FilterPanel/FilterPanelGroup/index.d.ts +1 -0
- package/es/components/InterstitialScreen/InterstitialScreen.d.ts +1 -25
- package/es/components/InterstitialScreen/InterstitialScreen.js +3 -19
- package/es/components/InterstitialScreen/InterstitialScreenBody.d.ts +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenBody.js +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenFooter.d.ts +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenFooter.js +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenHeader.d.ts +6 -0
- package/es/components/InterstitialScreen/InterstitialScreenHeader.js +1 -1
- package/es/components/InterstitialScreen/_story-assets/InterstitialScreenViewModule/InterstitialScreenViewModule.d.ts +1 -1
- package/es/components/InterstitialScreen/context.d.ts +31 -0
- package/es/components/InterstitialScreen/context.js +18 -0
- package/es/components/InterstitialScreen/index.d.ts +3 -2
- package/es/components/NotificationsPanel/NotificationsPanel.js +36 -13
- package/es/components/PageHeader/PageHeader.d.ts +2 -1
- package/es/components/PageHeader/PageHeader.js +2 -1
- package/es/components/PageHeader/next/PageHeader.d.ts +18 -3
- package/es/components/PageHeader/next/PageHeader.js +260 -12
- package/es/components/PageHeader/next/context.d.ts +25 -0
- package/es/components/PageHeader/next/context.js +30 -0
- package/es/components/PageHeader/next/index.d.ts +3 -3
- package/es/components/PageHeader/next/overflowHandler.d.ts +95 -0
- package/es/components/PageHeader/next/overflowHandler.js +162 -0
- package/es/components/PageHeader/next/utils.d.ts +19 -0
- package/es/components/PageHeader/next/utils.js +68 -0
- package/es/components/ProductiveCard/ProductiveCard.js +2 -1
- package/es/components/ScrollGradient/ScrollGradient.js +1 -2
- package/es/components/SidePanel/SidePanel.d.ts +4 -0
- package/es/components/SidePanel/SidePanel.js +8 -2
- package/es/components/Tearsheet/TearsheetShell.js +8 -5
- package/es/components/TruncatedText/TruncatedText.d.ts +48 -0
- package/es/components/TruncatedText/TruncatedText.js +86 -0
- package/es/components/TruncatedText/index.d.ts +7 -0
- package/es/components/TruncatedText/useTruncatedText.d.ts +16 -0
- package/es/components/TruncatedText/useTruncatedText.js +41 -0
- package/es/components/index.d.ts +4 -2
- package/es/global/js/hooks/useOverflowString.d.ts +2 -2
- package/es/global/js/hooks/useResizeObserver.d.ts +1 -1
- package/es/global/js/package-settings.d.ts +2 -1
- package/es/global/js/package-settings.js +3 -2
- package/es/global/js/utils/checkForOverflow.js +21 -0
- package/es/global/js/utils/makeDraggable/index.d.ts +1 -0
- package/es/global/js/utils/makeDraggable/makeDraggable.d.ts +19 -0
- package/es/global/js/utils/makeDraggable/makeDraggable.js +91 -0
- package/es/global/js/utils/makeDraggable/makeDraggable.stories.d.ts +22 -0
- package/es/index.js +4 -2
- package/es/node_modules/@floating-ui/core/dist/floating-ui.core.js +592 -0
- package/es/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +713 -0
- package/es/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +95 -0
- package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +161 -0
- package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +142 -0
- package/es/settings.d.ts +2 -1
- package/lib/components/{BigNumbers/BigNumbers.d.ts → BigNumber/BigNumber.d.ts} +5 -5
- package/lib/components/{BigNumbers/BigNumbers.js → BigNumber/BigNumber.js} +11 -11
- package/lib/components/BigNumber/BigNumberSkeleton.d.ts +17 -0
- package/lib/components/{BigNumbers/BigNumbersSkeleton.js → BigNumber/BigNumberSkeleton.js} +15 -15
- package/lib/components/{BigNumbers → BigNumber}/constants.d.ts +3 -3
- package/lib/components/{BigNumbers → BigNumber}/constants.js +6 -6
- package/lib/components/BigNumber/index.d.ts +7 -0
- package/lib/components/Coachmark/Coachmark.js +2 -2
- package/lib/components/Coachmark/next/Coachmark/Coachmark.d.ts +72 -0
- package/lib/components/Coachmark/next/Coachmark/Coachmark.js +189 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBeacon/CoachmarkBeacon.d.ts +44 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBeacon/index.d.ts +8 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.d.ts +38 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +127 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.d.ts +24 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.js +27 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/index.d.ts +10 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkContent.d.ts +34 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkContent.js +122 -0
- package/lib/components/Coachmark/next/Coachmark/ContentBody.d.ts +23 -0
- package/lib/components/Coachmark/next/Coachmark/ContentBody.js +41 -0
- package/lib/components/Coachmark/next/Coachmark/ContentHeader.d.ts +21 -0
- package/lib/components/Coachmark/next/Coachmark/ContentHeader.js +93 -0
- package/lib/components/Coachmark/next/Coachmark/index.d.ts +7 -0
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +0 -1
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +2 -2
- package/lib/components/CoachmarkStack/CoachmarkStack.js +2 -2
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -5
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +11 -4
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +1 -1
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +41 -2
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +5 -3
- package/lib/components/ConditionBuilder/utils/useTranslations.js +1 -1
- package/lib/components/EditInPlace/EditInPlace.js +0 -3
- package/lib/components/EmptyStates/EmptyState.d.ts +2 -2
- package/lib/components/EmptyStates/EmptyState.js +2 -8
- package/lib/components/FilterPanel/FilterPanelGroup/index.d.ts +1 -0
- package/lib/components/InterstitialScreen/InterstitialScreen.d.ts +1 -25
- package/lib/components/InterstitialScreen/InterstitialScreen.js +6 -25
- package/lib/components/InterstitialScreen/InterstitialScreenBody.d.ts +1 -1
- package/lib/components/InterstitialScreen/InterstitialScreenBody.js +6 -6
- package/lib/components/InterstitialScreen/InterstitialScreenFooter.d.ts +1 -1
- package/lib/components/InterstitialScreen/InterstitialScreenFooter.js +9 -9
- package/lib/components/InterstitialScreen/InterstitialScreenHeader.d.ts +6 -0
- package/lib/components/InterstitialScreen/InterstitialScreenHeader.js +5 -5
- package/lib/components/InterstitialScreen/_story-assets/InterstitialScreenViewModule/InterstitialScreenViewModule.d.ts +1 -1
- package/lib/components/InterstitialScreen/context.d.ts +31 -0
- package/lib/components/InterstitialScreen/context.js +21 -0
- package/lib/components/InterstitialScreen/index.d.ts +3 -2
- package/lib/components/NotificationsPanel/NotificationsPanel.js +36 -13
- package/lib/components/PageHeader/PageHeader.d.ts +2 -1
- package/lib/components/PageHeader/PageHeader.js +2 -1
- package/lib/components/PageHeader/next/PageHeader.d.ts +18 -3
- package/lib/components/PageHeader/next/PageHeader.js +261 -7
- package/lib/components/PageHeader/next/context.d.ts +25 -0
- package/lib/components/PageHeader/next/context.js +33 -0
- package/lib/components/PageHeader/next/index.d.ts +3 -3
- package/lib/components/PageHeader/next/overflowHandler.d.ts +95 -0
- package/lib/components/PageHeader/next/overflowHandler.js +166 -0
- package/lib/components/PageHeader/next/utils.d.ts +19 -0
- package/lib/components/PageHeader/next/utils.js +71 -0
- package/lib/components/ProductiveCard/ProductiveCard.js +2 -1
- package/lib/components/ScrollGradient/ScrollGradient.js +1 -2
- package/lib/components/SidePanel/SidePanel.d.ts +4 -0
- package/lib/components/SidePanel/SidePanel.js +8 -2
- package/lib/components/Tearsheet/TearsheetShell.js +8 -5
- package/lib/components/TruncatedText/TruncatedText.d.ts +48 -0
- package/lib/components/TruncatedText/TruncatedText.js +86 -0
- package/lib/components/TruncatedText/index.d.ts +7 -0
- package/lib/components/TruncatedText/useTruncatedText.d.ts +16 -0
- package/lib/components/TruncatedText/useTruncatedText.js +45 -0
- package/lib/components/index.d.ts +4 -2
- package/lib/global/js/hooks/useOverflowString.d.ts +2 -2
- package/lib/global/js/hooks/usePortalTarget.js +2 -2
- package/lib/global/js/hooks/useResizeObserver.d.ts +1 -1
- package/lib/global/js/package-settings.d.ts +2 -1
- package/lib/global/js/package-settings.js +3 -2
- package/lib/global/js/utils/checkForOverflow.js +23 -0
- package/lib/global/js/utils/makeDraggable/index.d.ts +1 -0
- package/lib/global/js/utils/makeDraggable/makeDraggable.d.ts +19 -0
- package/lib/global/js/utils/makeDraggable/makeDraggable.js +93 -0
- package/lib/global/js/utils/makeDraggable/makeDraggable.stories.d.ts +22 -0
- package/lib/index.js +11 -4
- package/lib/node_modules/@floating-ui/core/dist/floating-ui.core.js +600 -0
- package/lib/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +722 -0
- package/lib/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +102 -0
- package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +182 -0
- package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +164 -0
- package/lib/settings.d.ts +2 -1
- package/package.json +10 -11
- package/scss/components/{BigNumbers/_big-numbers.scss → BigNumber/_big-number.scss} +5 -5
- package/scss/components/{BigNumbers → BigNumber}/_carbon-imports.scss +3 -3
- package/scss/components/{BigNumbers → BigNumber}/_index-with-carbon.scss +2 -2
- package/scss/components/{BigNumbers → BigNumber}/_index.scss +2 -2
- package/scss/components/Card/_card.scss +2 -0
- package/scss/components/Coachmark/_bubble.scss +62 -0
- package/scss/components/Coachmark/_coachmark-beacon.scss +164 -0
- package/scss/components/Coachmark/_coachmark.scss +15 -0
- package/scss/components/ConditionBuilder/_condition-builder.scss +8 -0
- package/scss/components/PageHeader/_page-header.scss +144 -1
- package/scss/components/Tearsheet/_tearsheet.scss +6 -0
- package/scss/components/TruncatedText/_carbon-imports.scss +6 -0
- package/scss/components/TruncatedText/_index-with-carbon.scss +9 -0
- package/scss/components/TruncatedText/_index.scss +8 -0
- package/scss/components/TruncatedText/_truncated-text.scss +26 -0
- package/scss/components/_index-with-carbon.scss +3 -2
- package/scss/components/_index.scss +3 -2
- package/telemetry.yml +24 -5
- package/es/components/BigNumbers/BigNumbersSkeleton.d.ts +0 -17
- package/lib/components/BigNumbers/BigNumbersSkeleton.d.ts +0 -17
@@ -0,0 +1,722 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
var floatingUi_core = require('../../core/dist/floating-ui.core.js');
|
11
|
+
var floatingUi_utils = require('../../utils/dist/floating-ui.utils.js');
|
12
|
+
var floatingUi_utils_dom = require('../../utils/dist/floating-ui.utils.dom.js');
|
13
|
+
|
14
|
+
function getCssDimensions(element) {
|
15
|
+
const css = floatingUi_utils_dom.getComputedStyle(element);
|
16
|
+
// In testing environments, the `width` and `height` properties are empty
|
17
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
18
|
+
let width = parseFloat(css.width) || 0;
|
19
|
+
let height = parseFloat(css.height) || 0;
|
20
|
+
const hasOffset = floatingUi_utils_dom.isHTMLElement(element);
|
21
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
22
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
23
|
+
const shouldFallback = floatingUi_utils.round(width) !== offsetWidth || floatingUi_utils.round(height) !== offsetHeight;
|
24
|
+
if (shouldFallback) {
|
25
|
+
width = offsetWidth;
|
26
|
+
height = offsetHeight;
|
27
|
+
}
|
28
|
+
return {
|
29
|
+
width,
|
30
|
+
height,
|
31
|
+
$: shouldFallback
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
function unwrapElement(element) {
|
36
|
+
return !floatingUi_utils_dom.isElement(element) ? element.contextElement : element;
|
37
|
+
}
|
38
|
+
|
39
|
+
function getScale(element) {
|
40
|
+
const domElement = unwrapElement(element);
|
41
|
+
if (!floatingUi_utils_dom.isHTMLElement(domElement)) {
|
42
|
+
return floatingUi_utils.createCoords(1);
|
43
|
+
}
|
44
|
+
const rect = domElement.getBoundingClientRect();
|
45
|
+
const {
|
46
|
+
width,
|
47
|
+
height,
|
48
|
+
$
|
49
|
+
} = getCssDimensions(domElement);
|
50
|
+
let x = ($ ? floatingUi_utils.round(rect.width) : rect.width) / width;
|
51
|
+
let y = ($ ? floatingUi_utils.round(rect.height) : rect.height) / height;
|
52
|
+
|
53
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
54
|
+
|
55
|
+
if (!x || !Number.isFinite(x)) {
|
56
|
+
x = 1;
|
57
|
+
}
|
58
|
+
if (!y || !Number.isFinite(y)) {
|
59
|
+
y = 1;
|
60
|
+
}
|
61
|
+
return {
|
62
|
+
x,
|
63
|
+
y
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
const noOffsets = /*#__PURE__*/floatingUi_utils.createCoords(0);
|
68
|
+
function getVisualOffsets(element) {
|
69
|
+
const win = floatingUi_utils_dom.getWindow(element);
|
70
|
+
if (!floatingUi_utils_dom.isWebKit() || !win.visualViewport) {
|
71
|
+
return noOffsets;
|
72
|
+
}
|
73
|
+
return {
|
74
|
+
x: win.visualViewport.offsetLeft,
|
75
|
+
y: win.visualViewport.offsetTop
|
76
|
+
};
|
77
|
+
}
|
78
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
79
|
+
if (isFixed === void 0) {
|
80
|
+
isFixed = false;
|
81
|
+
}
|
82
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== floatingUi_utils_dom.getWindow(element)) {
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
return isFixed;
|
86
|
+
}
|
87
|
+
|
88
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
89
|
+
if (includeScale === void 0) {
|
90
|
+
includeScale = false;
|
91
|
+
}
|
92
|
+
if (isFixedStrategy === void 0) {
|
93
|
+
isFixedStrategy = false;
|
94
|
+
}
|
95
|
+
const clientRect = element.getBoundingClientRect();
|
96
|
+
const domElement = unwrapElement(element);
|
97
|
+
let scale = floatingUi_utils.createCoords(1);
|
98
|
+
if (includeScale) {
|
99
|
+
if (offsetParent) {
|
100
|
+
if (floatingUi_utils_dom.isElement(offsetParent)) {
|
101
|
+
scale = getScale(offsetParent);
|
102
|
+
}
|
103
|
+
} else {
|
104
|
+
scale = getScale(element);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : floatingUi_utils.createCoords(0);
|
108
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
109
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
110
|
+
let width = clientRect.width / scale.x;
|
111
|
+
let height = clientRect.height / scale.y;
|
112
|
+
if (domElement) {
|
113
|
+
const win = floatingUi_utils_dom.getWindow(domElement);
|
114
|
+
const offsetWin = offsetParent && floatingUi_utils_dom.isElement(offsetParent) ? floatingUi_utils_dom.getWindow(offsetParent) : offsetParent;
|
115
|
+
let currentWin = win;
|
116
|
+
let currentIFrame = floatingUi_utils_dom.getFrameElement(currentWin);
|
117
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
118
|
+
const iframeScale = getScale(currentIFrame);
|
119
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
120
|
+
const css = floatingUi_utils_dom.getComputedStyle(currentIFrame);
|
121
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
122
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
123
|
+
x *= iframeScale.x;
|
124
|
+
y *= iframeScale.y;
|
125
|
+
width *= iframeScale.x;
|
126
|
+
height *= iframeScale.y;
|
127
|
+
x += left;
|
128
|
+
y += top;
|
129
|
+
currentWin = floatingUi_utils_dom.getWindow(currentIFrame);
|
130
|
+
currentIFrame = floatingUi_utils_dom.getFrameElement(currentWin);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
return floatingUi_utils.rectToClientRect({
|
134
|
+
width,
|
135
|
+
height,
|
136
|
+
x,
|
137
|
+
y
|
138
|
+
});
|
139
|
+
}
|
140
|
+
|
141
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
142
|
+
// incorrect for RTL.
|
143
|
+
function getWindowScrollBarX(element, rect) {
|
144
|
+
const leftScroll = floatingUi_utils_dom.getNodeScroll(element).scrollLeft;
|
145
|
+
if (!rect) {
|
146
|
+
return getBoundingClientRect(floatingUi_utils_dom.getDocumentElement(element)).left + leftScroll;
|
147
|
+
}
|
148
|
+
return rect.left + leftScroll;
|
149
|
+
}
|
150
|
+
|
151
|
+
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
152
|
+
if (ignoreScrollbarX === void 0) {
|
153
|
+
ignoreScrollbarX = false;
|
154
|
+
}
|
155
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
156
|
+
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
|
157
|
+
// RTL <body> scrollbar.
|
158
|
+
getWindowScrollBarX(documentElement, htmlRect));
|
159
|
+
const y = htmlRect.top + scroll.scrollTop;
|
160
|
+
return {
|
161
|
+
x,
|
162
|
+
y
|
163
|
+
};
|
164
|
+
}
|
165
|
+
|
166
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
167
|
+
let {
|
168
|
+
elements,
|
169
|
+
rect,
|
170
|
+
offsetParent,
|
171
|
+
strategy
|
172
|
+
} = _ref;
|
173
|
+
const isFixed = strategy === 'fixed';
|
174
|
+
const documentElement = floatingUi_utils_dom.getDocumentElement(offsetParent);
|
175
|
+
const topLayer = elements ? floatingUi_utils_dom.isTopLayer(elements.floating) : false;
|
176
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
177
|
+
return rect;
|
178
|
+
}
|
179
|
+
let scroll = {
|
180
|
+
scrollLeft: 0,
|
181
|
+
scrollTop: 0
|
182
|
+
};
|
183
|
+
let scale = floatingUi_utils.createCoords(1);
|
184
|
+
const offsets = floatingUi_utils.createCoords(0);
|
185
|
+
const isOffsetParentAnElement = floatingUi_utils_dom.isHTMLElement(offsetParent);
|
186
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
187
|
+
if (floatingUi_utils_dom.getNodeName(offsetParent) !== 'body' || floatingUi_utils_dom.isOverflowElement(documentElement)) {
|
188
|
+
scroll = floatingUi_utils_dom.getNodeScroll(offsetParent);
|
189
|
+
}
|
190
|
+
if (floatingUi_utils_dom.isHTMLElement(offsetParent)) {
|
191
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
192
|
+
scale = getScale(offsetParent);
|
193
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
194
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : floatingUi_utils.createCoords(0);
|
198
|
+
return {
|
199
|
+
width: rect.width * scale.x,
|
200
|
+
height: rect.height * scale.y,
|
201
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
202
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
203
|
+
};
|
204
|
+
}
|
205
|
+
|
206
|
+
function getClientRects(element) {
|
207
|
+
return Array.from(element.getClientRects());
|
208
|
+
}
|
209
|
+
|
210
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
211
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
212
|
+
function getDocumentRect(element) {
|
213
|
+
const html = floatingUi_utils_dom.getDocumentElement(element);
|
214
|
+
const scroll = floatingUi_utils_dom.getNodeScroll(element);
|
215
|
+
const body = element.ownerDocument.body;
|
216
|
+
const width = floatingUi_utils.max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
217
|
+
const height = floatingUi_utils.max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
218
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
219
|
+
const y = -scroll.scrollTop;
|
220
|
+
if (floatingUi_utils_dom.getComputedStyle(body).direction === 'rtl') {
|
221
|
+
x += floatingUi_utils.max(html.clientWidth, body.clientWidth) - width;
|
222
|
+
}
|
223
|
+
return {
|
224
|
+
width,
|
225
|
+
height,
|
226
|
+
x,
|
227
|
+
y
|
228
|
+
};
|
229
|
+
}
|
230
|
+
|
231
|
+
function getViewportRect(element, strategy) {
|
232
|
+
const win = floatingUi_utils_dom.getWindow(element);
|
233
|
+
const html = floatingUi_utils_dom.getDocumentElement(element);
|
234
|
+
const visualViewport = win.visualViewport;
|
235
|
+
let width = html.clientWidth;
|
236
|
+
let height = html.clientHeight;
|
237
|
+
let x = 0;
|
238
|
+
let y = 0;
|
239
|
+
if (visualViewport) {
|
240
|
+
width = visualViewport.width;
|
241
|
+
height = visualViewport.height;
|
242
|
+
const visualViewportBased = floatingUi_utils_dom.isWebKit();
|
243
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
244
|
+
x = visualViewport.offsetLeft;
|
245
|
+
y = visualViewport.offsetTop;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
return {
|
249
|
+
width,
|
250
|
+
height,
|
251
|
+
x,
|
252
|
+
y
|
253
|
+
};
|
254
|
+
}
|
255
|
+
|
256
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
257
|
+
function getInnerBoundingClientRect(element, strategy) {
|
258
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
259
|
+
const top = clientRect.top + element.clientTop;
|
260
|
+
const left = clientRect.left + element.clientLeft;
|
261
|
+
const scale = floatingUi_utils_dom.isHTMLElement(element) ? getScale(element) : floatingUi_utils.createCoords(1);
|
262
|
+
const width = element.clientWidth * scale.x;
|
263
|
+
const height = element.clientHeight * scale.y;
|
264
|
+
const x = left * scale.x;
|
265
|
+
const y = top * scale.y;
|
266
|
+
return {
|
267
|
+
width,
|
268
|
+
height,
|
269
|
+
x,
|
270
|
+
y
|
271
|
+
};
|
272
|
+
}
|
273
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
274
|
+
let rect;
|
275
|
+
if (clippingAncestor === 'viewport') {
|
276
|
+
rect = getViewportRect(element, strategy);
|
277
|
+
} else if (clippingAncestor === 'document') {
|
278
|
+
rect = getDocumentRect(floatingUi_utils_dom.getDocumentElement(element));
|
279
|
+
} else if (floatingUi_utils_dom.isElement(clippingAncestor)) {
|
280
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
281
|
+
} else {
|
282
|
+
const visualOffsets = getVisualOffsets(element);
|
283
|
+
rect = {
|
284
|
+
x: clippingAncestor.x - visualOffsets.x,
|
285
|
+
y: clippingAncestor.y - visualOffsets.y,
|
286
|
+
width: clippingAncestor.width,
|
287
|
+
height: clippingAncestor.height
|
288
|
+
};
|
289
|
+
}
|
290
|
+
return floatingUi_utils.rectToClientRect(rect);
|
291
|
+
}
|
292
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
293
|
+
const parentNode = floatingUi_utils_dom.getParentNode(element);
|
294
|
+
if (parentNode === stopNode || !floatingUi_utils_dom.isElement(parentNode) || floatingUi_utils_dom.isLastTraversableNode(parentNode)) {
|
295
|
+
return false;
|
296
|
+
}
|
297
|
+
return floatingUi_utils_dom.getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
298
|
+
}
|
299
|
+
|
300
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
301
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
302
|
+
// of the given element up the tree.
|
303
|
+
function getClippingElementAncestors(element, cache) {
|
304
|
+
const cachedResult = cache.get(element);
|
305
|
+
if (cachedResult) {
|
306
|
+
return cachedResult;
|
307
|
+
}
|
308
|
+
let result = floatingUi_utils_dom.getOverflowAncestors(element, [], false).filter(el => floatingUi_utils_dom.isElement(el) && floatingUi_utils_dom.getNodeName(el) !== 'body');
|
309
|
+
let currentContainingBlockComputedStyle = null;
|
310
|
+
const elementIsFixed = floatingUi_utils_dom.getComputedStyle(element).position === 'fixed';
|
311
|
+
let currentNode = elementIsFixed ? floatingUi_utils_dom.getParentNode(element) : element;
|
312
|
+
|
313
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
314
|
+
while (floatingUi_utils_dom.isElement(currentNode) && !floatingUi_utils_dom.isLastTraversableNode(currentNode)) {
|
315
|
+
const computedStyle = floatingUi_utils_dom.getComputedStyle(currentNode);
|
316
|
+
const currentNodeIsContaining = floatingUi_utils_dom.isContainingBlock(currentNode);
|
317
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
318
|
+
currentContainingBlockComputedStyle = null;
|
319
|
+
}
|
320
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || floatingUi_utils_dom.isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
321
|
+
if (shouldDropCurrentNode) {
|
322
|
+
// Drop non-containing blocks.
|
323
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
324
|
+
} else {
|
325
|
+
// Record last containing block for next iteration.
|
326
|
+
currentContainingBlockComputedStyle = computedStyle;
|
327
|
+
}
|
328
|
+
currentNode = floatingUi_utils_dom.getParentNode(currentNode);
|
329
|
+
}
|
330
|
+
cache.set(element, result);
|
331
|
+
return result;
|
332
|
+
}
|
333
|
+
|
334
|
+
// Gets the maximum area that the element is visible in due to any number of
|
335
|
+
// clipping ancestors.
|
336
|
+
function getClippingRect(_ref) {
|
337
|
+
let {
|
338
|
+
element,
|
339
|
+
boundary,
|
340
|
+
rootBoundary,
|
341
|
+
strategy
|
342
|
+
} = _ref;
|
343
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? floatingUi_utils_dom.isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
344
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
345
|
+
const firstClippingAncestor = clippingAncestors[0];
|
346
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
347
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
348
|
+
accRect.top = floatingUi_utils.max(rect.top, accRect.top);
|
349
|
+
accRect.right = floatingUi_utils.min(rect.right, accRect.right);
|
350
|
+
accRect.bottom = floatingUi_utils.min(rect.bottom, accRect.bottom);
|
351
|
+
accRect.left = floatingUi_utils.max(rect.left, accRect.left);
|
352
|
+
return accRect;
|
353
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
354
|
+
return {
|
355
|
+
width: clippingRect.right - clippingRect.left,
|
356
|
+
height: clippingRect.bottom - clippingRect.top,
|
357
|
+
x: clippingRect.left,
|
358
|
+
y: clippingRect.top
|
359
|
+
};
|
360
|
+
}
|
361
|
+
|
362
|
+
function getDimensions(element) {
|
363
|
+
const {
|
364
|
+
width,
|
365
|
+
height
|
366
|
+
} = getCssDimensions(element);
|
367
|
+
return {
|
368
|
+
width,
|
369
|
+
height
|
370
|
+
};
|
371
|
+
}
|
372
|
+
|
373
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
374
|
+
const isOffsetParentAnElement = floatingUi_utils_dom.isHTMLElement(offsetParent);
|
375
|
+
const documentElement = floatingUi_utils_dom.getDocumentElement(offsetParent);
|
376
|
+
const isFixed = strategy === 'fixed';
|
377
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
378
|
+
let scroll = {
|
379
|
+
scrollLeft: 0,
|
380
|
+
scrollTop: 0
|
381
|
+
};
|
382
|
+
const offsets = floatingUi_utils.createCoords(0);
|
383
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
384
|
+
if (floatingUi_utils_dom.getNodeName(offsetParent) !== 'body' || floatingUi_utils_dom.isOverflowElement(documentElement)) {
|
385
|
+
scroll = floatingUi_utils_dom.getNodeScroll(offsetParent);
|
386
|
+
}
|
387
|
+
if (isOffsetParentAnElement) {
|
388
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
389
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
390
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
391
|
+
} else if (documentElement) {
|
392
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
393
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
394
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
395
|
+
}
|
396
|
+
}
|
397
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : floatingUi_utils.createCoords(0);
|
398
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
399
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
400
|
+
return {
|
401
|
+
x,
|
402
|
+
y,
|
403
|
+
width: rect.width,
|
404
|
+
height: rect.height
|
405
|
+
};
|
406
|
+
}
|
407
|
+
|
408
|
+
function isStaticPositioned(element) {
|
409
|
+
return floatingUi_utils_dom.getComputedStyle(element).position === 'static';
|
410
|
+
}
|
411
|
+
|
412
|
+
function getTrueOffsetParent(element, polyfill) {
|
413
|
+
if (!floatingUi_utils_dom.isHTMLElement(element) || floatingUi_utils_dom.getComputedStyle(element).position === 'fixed') {
|
414
|
+
return null;
|
415
|
+
}
|
416
|
+
if (polyfill) {
|
417
|
+
return polyfill(element);
|
418
|
+
}
|
419
|
+
let rawOffsetParent = element.offsetParent;
|
420
|
+
|
421
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
422
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
423
|
+
// be used to perform the correct calculations even if the <html> element is
|
424
|
+
// non-static.
|
425
|
+
if (floatingUi_utils_dom.getDocumentElement(element) === rawOffsetParent) {
|
426
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
427
|
+
}
|
428
|
+
return rawOffsetParent;
|
429
|
+
}
|
430
|
+
|
431
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
432
|
+
// such as table ancestors and cross browser bugs.
|
433
|
+
function getOffsetParent(element, polyfill) {
|
434
|
+
const win = floatingUi_utils_dom.getWindow(element);
|
435
|
+
if (floatingUi_utils_dom.isTopLayer(element)) {
|
436
|
+
return win;
|
437
|
+
}
|
438
|
+
if (!floatingUi_utils_dom.isHTMLElement(element)) {
|
439
|
+
let svgOffsetParent = floatingUi_utils_dom.getParentNode(element);
|
440
|
+
while (svgOffsetParent && !floatingUi_utils_dom.isLastTraversableNode(svgOffsetParent)) {
|
441
|
+
if (floatingUi_utils_dom.isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
442
|
+
return svgOffsetParent;
|
443
|
+
}
|
444
|
+
svgOffsetParent = floatingUi_utils_dom.getParentNode(svgOffsetParent);
|
445
|
+
}
|
446
|
+
return win;
|
447
|
+
}
|
448
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
449
|
+
while (offsetParent && floatingUi_utils_dom.isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
450
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
451
|
+
}
|
452
|
+
if (offsetParent && floatingUi_utils_dom.isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !floatingUi_utils_dom.isContainingBlock(offsetParent)) {
|
453
|
+
return win;
|
454
|
+
}
|
455
|
+
return offsetParent || floatingUi_utils_dom.getContainingBlock(element) || win;
|
456
|
+
}
|
457
|
+
|
458
|
+
const getElementRects = async function (data) {
|
459
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
460
|
+
const getDimensionsFn = this.getDimensions;
|
461
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
462
|
+
return {
|
463
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
464
|
+
floating: {
|
465
|
+
x: 0,
|
466
|
+
y: 0,
|
467
|
+
width: floatingDimensions.width,
|
468
|
+
height: floatingDimensions.height
|
469
|
+
}
|
470
|
+
};
|
471
|
+
};
|
472
|
+
|
473
|
+
function isRTL(element) {
|
474
|
+
return floatingUi_utils_dom.getComputedStyle(element).direction === 'rtl';
|
475
|
+
}
|
476
|
+
|
477
|
+
const platform = {
|
478
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
479
|
+
getDocumentElement: floatingUi_utils_dom.getDocumentElement,
|
480
|
+
getClippingRect,
|
481
|
+
getOffsetParent,
|
482
|
+
getElementRects,
|
483
|
+
getClientRects,
|
484
|
+
getDimensions,
|
485
|
+
getScale,
|
486
|
+
isElement: floatingUi_utils_dom.isElement,
|
487
|
+
isRTL
|
488
|
+
};
|
489
|
+
|
490
|
+
function rectsAreEqual(a, b) {
|
491
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
492
|
+
}
|
493
|
+
|
494
|
+
// https://samthor.au/2021/observing-dom/
|
495
|
+
function observeMove(element, onMove) {
|
496
|
+
let io = null;
|
497
|
+
let timeoutId;
|
498
|
+
const root = floatingUi_utils_dom.getDocumentElement(element);
|
499
|
+
function cleanup() {
|
500
|
+
var _io;
|
501
|
+
clearTimeout(timeoutId);
|
502
|
+
(_io = io) == null || _io.disconnect();
|
503
|
+
io = null;
|
504
|
+
}
|
505
|
+
function refresh(skip, threshold) {
|
506
|
+
if (skip === void 0) {
|
507
|
+
skip = false;
|
508
|
+
}
|
509
|
+
if (threshold === void 0) {
|
510
|
+
threshold = 1;
|
511
|
+
}
|
512
|
+
cleanup();
|
513
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
514
|
+
const {
|
515
|
+
left,
|
516
|
+
top,
|
517
|
+
width,
|
518
|
+
height
|
519
|
+
} = elementRectForRootMargin;
|
520
|
+
if (!skip) {
|
521
|
+
onMove();
|
522
|
+
}
|
523
|
+
if (!width || !height) {
|
524
|
+
return;
|
525
|
+
}
|
526
|
+
const insetTop = floatingUi_utils.floor(top);
|
527
|
+
const insetRight = floatingUi_utils.floor(root.clientWidth - (left + width));
|
528
|
+
const insetBottom = floatingUi_utils.floor(root.clientHeight - (top + height));
|
529
|
+
const insetLeft = floatingUi_utils.floor(left);
|
530
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
531
|
+
const options = {
|
532
|
+
rootMargin,
|
533
|
+
threshold: floatingUi_utils.max(0, floatingUi_utils.min(1, threshold)) || 1
|
534
|
+
};
|
535
|
+
let isFirstUpdate = true;
|
536
|
+
function handleObserve(entries) {
|
537
|
+
const ratio = entries[0].intersectionRatio;
|
538
|
+
if (ratio !== threshold) {
|
539
|
+
if (!isFirstUpdate) {
|
540
|
+
return refresh();
|
541
|
+
}
|
542
|
+
if (!ratio) {
|
543
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
544
|
+
// to prevent an infinite loop of updates.
|
545
|
+
timeoutId = setTimeout(() => {
|
546
|
+
refresh(false, 1e-7);
|
547
|
+
}, 1000);
|
548
|
+
} else {
|
549
|
+
refresh(false, ratio);
|
550
|
+
}
|
551
|
+
}
|
552
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
553
|
+
// It's possible that even though the ratio is reported as 1, the
|
554
|
+
// element is not actually fully within the IntersectionObserver's root
|
555
|
+
// area anymore. This can happen under performance constraints. This may
|
556
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
557
|
+
// work around this, we compare the element's bounding rect now with
|
558
|
+
// what it was at the time we created the IntersectionObserver. If they
|
559
|
+
// are not equal then the element moved, so we refresh.
|
560
|
+
refresh();
|
561
|
+
}
|
562
|
+
isFirstUpdate = false;
|
563
|
+
}
|
564
|
+
|
565
|
+
// Older browsers don't support a `document` as the root and will throw an
|
566
|
+
// error.
|
567
|
+
try {
|
568
|
+
io = new IntersectionObserver(handleObserve, {
|
569
|
+
...options,
|
570
|
+
// Handle <iframe>s
|
571
|
+
root: root.ownerDocument
|
572
|
+
});
|
573
|
+
} catch (e) {
|
574
|
+
io = new IntersectionObserver(handleObserve, options);
|
575
|
+
}
|
576
|
+
io.observe(element);
|
577
|
+
}
|
578
|
+
refresh(true);
|
579
|
+
return cleanup;
|
580
|
+
}
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Automatically updates the position of the floating element when necessary.
|
584
|
+
* Should only be called when the floating element is mounted on the DOM or
|
585
|
+
* visible on the screen.
|
586
|
+
* @returns cleanup function that should be invoked when the floating element is
|
587
|
+
* removed from the DOM or hidden from the screen.
|
588
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
589
|
+
*/
|
590
|
+
function autoUpdate(reference, floating, update, options) {
|
591
|
+
if (options === void 0) {
|
592
|
+
options = {};
|
593
|
+
}
|
594
|
+
const {
|
595
|
+
ancestorScroll = true,
|
596
|
+
ancestorResize = true,
|
597
|
+
elementResize = typeof ResizeObserver === 'function',
|
598
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
599
|
+
animationFrame = false
|
600
|
+
} = options;
|
601
|
+
const referenceEl = unwrapElement(reference);
|
602
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? floatingUi_utils_dom.getOverflowAncestors(referenceEl) : []), ...floatingUi_utils_dom.getOverflowAncestors(floating)] : [];
|
603
|
+
ancestors.forEach(ancestor => {
|
604
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
605
|
+
passive: true
|
606
|
+
});
|
607
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
608
|
+
});
|
609
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
610
|
+
let reobserveFrame = -1;
|
611
|
+
let resizeObserver = null;
|
612
|
+
if (elementResize) {
|
613
|
+
resizeObserver = new ResizeObserver(_ref => {
|
614
|
+
let [firstEntry] = _ref;
|
615
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
616
|
+
// Prevent update loops when using the `size` middleware.
|
617
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
618
|
+
resizeObserver.unobserve(floating);
|
619
|
+
cancelAnimationFrame(reobserveFrame);
|
620
|
+
reobserveFrame = requestAnimationFrame(() => {
|
621
|
+
var _resizeObserver;
|
622
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
623
|
+
});
|
624
|
+
}
|
625
|
+
update();
|
626
|
+
});
|
627
|
+
if (referenceEl && !animationFrame) {
|
628
|
+
resizeObserver.observe(referenceEl);
|
629
|
+
}
|
630
|
+
resizeObserver.observe(floating);
|
631
|
+
}
|
632
|
+
let frameId;
|
633
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
634
|
+
if (animationFrame) {
|
635
|
+
frameLoop();
|
636
|
+
}
|
637
|
+
function frameLoop() {
|
638
|
+
const nextRefRect = getBoundingClientRect(reference);
|
639
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
640
|
+
update();
|
641
|
+
}
|
642
|
+
prevRefRect = nextRefRect;
|
643
|
+
frameId = requestAnimationFrame(frameLoop);
|
644
|
+
}
|
645
|
+
update();
|
646
|
+
return () => {
|
647
|
+
var _resizeObserver2;
|
648
|
+
ancestors.forEach(ancestor => {
|
649
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
650
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
651
|
+
});
|
652
|
+
cleanupIo == null || cleanupIo();
|
653
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
654
|
+
resizeObserver = null;
|
655
|
+
if (animationFrame) {
|
656
|
+
cancelAnimationFrame(frameId);
|
657
|
+
}
|
658
|
+
};
|
659
|
+
}
|
660
|
+
|
661
|
+
/**
|
662
|
+
* Modifies the placement by translating the floating element along the
|
663
|
+
* specified axes.
|
664
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
665
|
+
* object may be passed.
|
666
|
+
* @see https://floating-ui.com/docs/offset
|
667
|
+
*/
|
668
|
+
const offset = floatingUi_core.offset;
|
669
|
+
|
670
|
+
/**
|
671
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
672
|
+
* keep it in view when it will overflow the clipping boundary.
|
673
|
+
* @see https://floating-ui.com/docs/shift
|
674
|
+
*/
|
675
|
+
const shift = floatingUi_core.shift;
|
676
|
+
|
677
|
+
/**
|
678
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
679
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
680
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
681
|
+
* @see https://floating-ui.com/docs/flip
|
682
|
+
*/
|
683
|
+
const flip = floatingUi_core.flip;
|
684
|
+
|
685
|
+
/**
|
686
|
+
* Provides data to position an inner element of the floating element so that it
|
687
|
+
* appears centered to the reference element.
|
688
|
+
* @see https://floating-ui.com/docs/arrow
|
689
|
+
*/
|
690
|
+
const arrow = floatingUi_core.arrow;
|
691
|
+
|
692
|
+
/**
|
693
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
694
|
+
* next to a given reference element.
|
695
|
+
*/
|
696
|
+
const computePosition = (reference, floating, options) => {
|
697
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
698
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
699
|
+
// single call. If other functions become expensive, we can add them as well.
|
700
|
+
const cache = new Map();
|
701
|
+
const mergedOptions = {
|
702
|
+
platform,
|
703
|
+
...options
|
704
|
+
};
|
705
|
+
const platformWithCache = {
|
706
|
+
...mergedOptions.platform,
|
707
|
+
_c: cache
|
708
|
+
};
|
709
|
+
return floatingUi_core.computePosition(reference, floating, {
|
710
|
+
...mergedOptions,
|
711
|
+
platform: platformWithCache
|
712
|
+
});
|
713
|
+
};
|
714
|
+
|
715
|
+
exports.getOverflowAncestors = floatingUi_utils_dom.getOverflowAncestors;
|
716
|
+
exports.arrow = arrow;
|
717
|
+
exports.autoUpdate = autoUpdate;
|
718
|
+
exports.computePosition = computePosition;
|
719
|
+
exports.flip = flip;
|
720
|
+
exports.offset = offset;
|
721
|
+
exports.platform = platform;
|
722
|
+
exports.shift = shift;
|