@carbon/ibm-products 2.71.1 → 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 +3 -1
- 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 +3 -1
- 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 +3 -1
- 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 +10 -3
- 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 +9 -10
- 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
package/lib/index.js
CHANGED
@@ -84,6 +84,7 @@ var Checklist = require('./components/Checklist/Checklist.js');
|
|
84
84
|
var Coachmark = require('./components/Coachmark/Coachmark.js');
|
85
85
|
require('react');
|
86
86
|
require('./components/Coachmark/CoachmarkTagline.js');
|
87
|
+
var Coachmark$1 = require('./components/Coachmark/next/Coachmark/Coachmark.js');
|
87
88
|
var CoachmarkBeacon = require('./components/CoachmarkBeacon/CoachmarkBeacon.js');
|
88
89
|
var CoachmarkButton = require('./components/CoachmarkButton/CoachmarkButton.js');
|
89
90
|
var CoachmarkFixed = require('./components/CoachmarkFixed/CoachmarkFixed.js');
|
@@ -97,8 +98,9 @@ var InlineTip = require('./components/InlineTip/InlineTip.js');
|
|
97
98
|
var InlineTipButton = require('./components/InlineTip/InlineTipButton.js');
|
98
99
|
var InlineTipLink = require('./components/InlineTip/InlineTipLink.js');
|
99
100
|
var NonLinearReading = require('./components/NonLinearReading/NonLinearReading.js');
|
100
|
-
var
|
101
|
+
var BigNumber = require('./components/BigNumber/BigNumber.js');
|
101
102
|
var TruncatedList = require('./components/TruncatedList/TruncatedList.js');
|
103
|
+
var TruncatedText = require('./components/TruncatedText/TruncatedText.js');
|
102
104
|
var InterstitialScreen = require('./components/InterstitialScreen/InterstitialScreen.js');
|
103
105
|
var DelimitedList = require('./components/DelimitedList/DelimitedList.js');
|
104
106
|
var FullPageError = require('./components/FullPageError/FullPageError.js');
|
@@ -372,6 +374,7 @@ Object.defineProperty(exports, "Coachmark", {
|
|
372
374
|
enumerable: true,
|
373
375
|
get: function () { return Coachmark.Coachmark; }
|
374
376
|
});
|
377
|
+
exports.preview__Coachmark = Coachmark$1.Coachmark;
|
375
378
|
Object.defineProperty(exports, "CoachmarkBeacon", {
|
376
379
|
enumerable: true,
|
377
380
|
get: function () { return CoachmarkBeacon.CoachmarkBeacon; }
|
@@ -424,14 +427,18 @@ Object.defineProperty(exports, "NonLinearReading", {
|
|
424
427
|
enumerable: true,
|
425
428
|
get: function () { return NonLinearReading.NonLinearReading; }
|
426
429
|
});
|
427
|
-
Object.defineProperty(exports, "
|
430
|
+
Object.defineProperty(exports, "BigNumber", {
|
428
431
|
enumerable: true,
|
429
|
-
get: function () { return
|
432
|
+
get: function () { return BigNumber.BigNumber; }
|
430
433
|
});
|
431
434
|
Object.defineProperty(exports, "TruncatedList", {
|
432
435
|
enumerable: true,
|
433
436
|
get: function () { return TruncatedList.TruncatedList; }
|
434
437
|
});
|
438
|
+
Object.defineProperty(exports, "TruncatedText", {
|
439
|
+
enumerable: true,
|
440
|
+
get: function () { return TruncatedText.TruncatedText; }
|
441
|
+
});
|
435
442
|
Object.defineProperty(exports, "InterstitialScreen", {
|
436
443
|
enumerable: true,
|
437
444
|
get: function () { return InterstitialScreen.InterstitialScreen; }
|
@@ -0,0 +1,600 @@
|
|
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_utils = require('../../utils/dist/floating-ui.utils.js');
|
11
|
+
|
12
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
13
|
+
let {
|
14
|
+
reference,
|
15
|
+
floating
|
16
|
+
} = _ref;
|
17
|
+
const sideAxis = floatingUi_utils.getSideAxis(placement);
|
18
|
+
const alignmentAxis = floatingUi_utils.getAlignmentAxis(placement);
|
19
|
+
const alignLength = floatingUi_utils.getAxisLength(alignmentAxis);
|
20
|
+
const side = floatingUi_utils.getSide(placement);
|
21
|
+
const isVertical = sideAxis === 'y';
|
22
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
23
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
24
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
25
|
+
let coords;
|
26
|
+
switch (side) {
|
27
|
+
case 'top':
|
28
|
+
coords = {
|
29
|
+
x: commonX,
|
30
|
+
y: reference.y - floating.height
|
31
|
+
};
|
32
|
+
break;
|
33
|
+
case 'bottom':
|
34
|
+
coords = {
|
35
|
+
x: commonX,
|
36
|
+
y: reference.y + reference.height
|
37
|
+
};
|
38
|
+
break;
|
39
|
+
case 'right':
|
40
|
+
coords = {
|
41
|
+
x: reference.x + reference.width,
|
42
|
+
y: commonY
|
43
|
+
};
|
44
|
+
break;
|
45
|
+
case 'left':
|
46
|
+
coords = {
|
47
|
+
x: reference.x - floating.width,
|
48
|
+
y: commonY
|
49
|
+
};
|
50
|
+
break;
|
51
|
+
default:
|
52
|
+
coords = {
|
53
|
+
x: reference.x,
|
54
|
+
y: reference.y
|
55
|
+
};
|
56
|
+
}
|
57
|
+
switch (floatingUi_utils.getAlignment(placement)) {
|
58
|
+
case 'start':
|
59
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
60
|
+
break;
|
61
|
+
case 'end':
|
62
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
return coords;
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
70
|
+
* next to a given reference element.
|
71
|
+
*
|
72
|
+
* This export does not have any `platform` interface logic. You will need to
|
73
|
+
* write one for the platform you are using Floating UI with.
|
74
|
+
*/
|
75
|
+
const computePosition = async (reference, floating, config) => {
|
76
|
+
const {
|
77
|
+
placement = 'bottom',
|
78
|
+
strategy = 'absolute',
|
79
|
+
middleware = [],
|
80
|
+
platform
|
81
|
+
} = config;
|
82
|
+
const validMiddleware = middleware.filter(Boolean);
|
83
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
84
|
+
let rects = await platform.getElementRects({
|
85
|
+
reference,
|
86
|
+
floating,
|
87
|
+
strategy
|
88
|
+
});
|
89
|
+
let {
|
90
|
+
x,
|
91
|
+
y
|
92
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
93
|
+
let statefulPlacement = placement;
|
94
|
+
let middlewareData = {};
|
95
|
+
let resetCount = 0;
|
96
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
97
|
+
const {
|
98
|
+
name,
|
99
|
+
fn
|
100
|
+
} = validMiddleware[i];
|
101
|
+
const {
|
102
|
+
x: nextX,
|
103
|
+
y: nextY,
|
104
|
+
data,
|
105
|
+
reset
|
106
|
+
} = await fn({
|
107
|
+
x,
|
108
|
+
y,
|
109
|
+
initialPlacement: placement,
|
110
|
+
placement: statefulPlacement,
|
111
|
+
strategy,
|
112
|
+
middlewareData,
|
113
|
+
rects,
|
114
|
+
platform,
|
115
|
+
elements: {
|
116
|
+
reference,
|
117
|
+
floating
|
118
|
+
}
|
119
|
+
});
|
120
|
+
x = nextX != null ? nextX : x;
|
121
|
+
y = nextY != null ? nextY : y;
|
122
|
+
middlewareData = {
|
123
|
+
...middlewareData,
|
124
|
+
[name]: {
|
125
|
+
...middlewareData[name],
|
126
|
+
...data
|
127
|
+
}
|
128
|
+
};
|
129
|
+
if (reset && resetCount <= 50) {
|
130
|
+
resetCount++;
|
131
|
+
if (typeof reset === 'object') {
|
132
|
+
if (reset.placement) {
|
133
|
+
statefulPlacement = reset.placement;
|
134
|
+
}
|
135
|
+
if (reset.rects) {
|
136
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
137
|
+
reference,
|
138
|
+
floating,
|
139
|
+
strategy
|
140
|
+
}) : reset.rects;
|
141
|
+
}
|
142
|
+
({
|
143
|
+
x,
|
144
|
+
y
|
145
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
146
|
+
}
|
147
|
+
i = -1;
|
148
|
+
}
|
149
|
+
}
|
150
|
+
return {
|
151
|
+
x,
|
152
|
+
y,
|
153
|
+
placement: statefulPlacement,
|
154
|
+
strategy,
|
155
|
+
middlewareData
|
156
|
+
};
|
157
|
+
};
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
161
|
+
* element is overflowing a given clipping boundary on each side.
|
162
|
+
* - positive = overflowing the boundary by that number of pixels
|
163
|
+
* - negative = how many pixels left before it will overflow
|
164
|
+
* - 0 = lies flush with the boundary
|
165
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
166
|
+
*/
|
167
|
+
async function detectOverflow(state, options) {
|
168
|
+
var _await$platform$isEle;
|
169
|
+
if (options === void 0) {
|
170
|
+
options = {};
|
171
|
+
}
|
172
|
+
const {
|
173
|
+
x,
|
174
|
+
y,
|
175
|
+
platform,
|
176
|
+
rects,
|
177
|
+
elements,
|
178
|
+
strategy
|
179
|
+
} = state;
|
180
|
+
const {
|
181
|
+
boundary = 'clippingAncestors',
|
182
|
+
rootBoundary = 'viewport',
|
183
|
+
elementContext = 'floating',
|
184
|
+
altBoundary = false,
|
185
|
+
padding = 0
|
186
|
+
} = floatingUi_utils.evaluate(options, state);
|
187
|
+
const paddingObject = floatingUi_utils.getPaddingObject(padding);
|
188
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
189
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
190
|
+
const clippingClientRect = floatingUi_utils.rectToClientRect(await platform.getClippingRect({
|
191
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
192
|
+
boundary,
|
193
|
+
rootBoundary,
|
194
|
+
strategy
|
195
|
+
}));
|
196
|
+
const rect = elementContext === 'floating' ? {
|
197
|
+
x,
|
198
|
+
y,
|
199
|
+
width: rects.floating.width,
|
200
|
+
height: rects.floating.height
|
201
|
+
} : rects.reference;
|
202
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
203
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
204
|
+
x: 1,
|
205
|
+
y: 1
|
206
|
+
} : {
|
207
|
+
x: 1,
|
208
|
+
y: 1
|
209
|
+
};
|
210
|
+
const elementClientRect = floatingUi_utils.rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
211
|
+
elements,
|
212
|
+
rect,
|
213
|
+
offsetParent,
|
214
|
+
strategy
|
215
|
+
}) : rect);
|
216
|
+
return {
|
217
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
218
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
219
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
220
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
221
|
+
};
|
222
|
+
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Provides data to position an inner element of the floating element so that it
|
226
|
+
* appears centered to the reference element.
|
227
|
+
* @see https://floating-ui.com/docs/arrow
|
228
|
+
*/
|
229
|
+
const arrow = options => ({
|
230
|
+
name: 'arrow',
|
231
|
+
options,
|
232
|
+
async fn(state) {
|
233
|
+
const {
|
234
|
+
x,
|
235
|
+
y,
|
236
|
+
placement,
|
237
|
+
rects,
|
238
|
+
platform,
|
239
|
+
elements,
|
240
|
+
middlewareData
|
241
|
+
} = state;
|
242
|
+
// Since `element` is required, we don't Partial<> the type.
|
243
|
+
const {
|
244
|
+
element,
|
245
|
+
padding = 0
|
246
|
+
} = floatingUi_utils.evaluate(options, state) || {};
|
247
|
+
if (element == null) {
|
248
|
+
return {};
|
249
|
+
}
|
250
|
+
const paddingObject = floatingUi_utils.getPaddingObject(padding);
|
251
|
+
const coords = {
|
252
|
+
x,
|
253
|
+
y
|
254
|
+
};
|
255
|
+
const axis = floatingUi_utils.getAlignmentAxis(placement);
|
256
|
+
const length = floatingUi_utils.getAxisLength(axis);
|
257
|
+
const arrowDimensions = await platform.getDimensions(element);
|
258
|
+
const isYAxis = axis === 'y';
|
259
|
+
const minProp = isYAxis ? 'top' : 'left';
|
260
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
261
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
262
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
263
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
264
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
265
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
266
|
+
|
267
|
+
// DOM platform can return `window` as the `offsetParent`.
|
268
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
269
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
270
|
+
}
|
271
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
272
|
+
|
273
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
274
|
+
// centered, modify the padding so that it is centered.
|
275
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
276
|
+
const minPadding = floatingUi_utils.min(paddingObject[minProp], largestPossiblePadding);
|
277
|
+
const maxPadding = floatingUi_utils.min(paddingObject[maxProp], largestPossiblePadding);
|
278
|
+
|
279
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
280
|
+
// point is outside the floating element's bounds.
|
281
|
+
const min$1 = minPadding;
|
282
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
283
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
284
|
+
const offset = floatingUi_utils.clamp(min$1, center, max);
|
285
|
+
|
286
|
+
// If the reference is small enough that the arrow's padding causes it to
|
287
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
288
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
289
|
+
// a single reset is performed when this is true.
|
290
|
+
const shouldAddOffset = !middlewareData.arrow && floatingUi_utils.getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
291
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
292
|
+
return {
|
293
|
+
[axis]: coords[axis] + alignmentOffset,
|
294
|
+
data: {
|
295
|
+
[axis]: offset,
|
296
|
+
centerOffset: center - offset - alignmentOffset,
|
297
|
+
...(shouldAddOffset && {
|
298
|
+
alignmentOffset
|
299
|
+
})
|
300
|
+
},
|
301
|
+
reset: shouldAddOffset
|
302
|
+
};
|
303
|
+
}
|
304
|
+
});
|
305
|
+
|
306
|
+
/**
|
307
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
308
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
309
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
310
|
+
* @see https://floating-ui.com/docs/flip
|
311
|
+
*/
|
312
|
+
const flip = function (options) {
|
313
|
+
if (options === void 0) {
|
314
|
+
options = {};
|
315
|
+
}
|
316
|
+
return {
|
317
|
+
name: 'flip',
|
318
|
+
options,
|
319
|
+
async fn(state) {
|
320
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
321
|
+
const {
|
322
|
+
placement,
|
323
|
+
middlewareData,
|
324
|
+
rects,
|
325
|
+
initialPlacement,
|
326
|
+
platform,
|
327
|
+
elements
|
328
|
+
} = state;
|
329
|
+
const {
|
330
|
+
mainAxis: checkMainAxis = true,
|
331
|
+
crossAxis: checkCrossAxis = true,
|
332
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
333
|
+
fallbackStrategy = 'bestFit',
|
334
|
+
fallbackAxisSideDirection = 'none',
|
335
|
+
flipAlignment = true,
|
336
|
+
...detectOverflowOptions
|
337
|
+
} = floatingUi_utils.evaluate(options, state);
|
338
|
+
|
339
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
340
|
+
// added, we should skip any logic now since `flip()` has already done its
|
341
|
+
// work.
|
342
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
343
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
344
|
+
return {};
|
345
|
+
}
|
346
|
+
const side = floatingUi_utils.getSide(placement);
|
347
|
+
const initialSideAxis = floatingUi_utils.getSideAxis(initialPlacement);
|
348
|
+
const isBasePlacement = floatingUi_utils.getSide(initialPlacement) === initialPlacement;
|
349
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
350
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [floatingUi_utils.getOppositePlacement(initialPlacement)] : floatingUi_utils.getExpandedPlacements(initialPlacement));
|
351
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
352
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
353
|
+
fallbackPlacements.push(...floatingUi_utils.getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
354
|
+
}
|
355
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
356
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
357
|
+
const overflows = [];
|
358
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
359
|
+
if (checkMainAxis) {
|
360
|
+
overflows.push(overflow[side]);
|
361
|
+
}
|
362
|
+
if (checkCrossAxis) {
|
363
|
+
const sides = floatingUi_utils.getAlignmentSides(placement, rects, rtl);
|
364
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
365
|
+
}
|
366
|
+
overflowsData = [...overflowsData, {
|
367
|
+
placement,
|
368
|
+
overflows
|
369
|
+
}];
|
370
|
+
|
371
|
+
// One or more sides is overflowing.
|
372
|
+
if (!overflows.every(side => side <= 0)) {
|
373
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
374
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
375
|
+
const nextPlacement = placements[nextIndex];
|
376
|
+
if (nextPlacement) {
|
377
|
+
// Try next placement and re-run the lifecycle.
|
378
|
+
return {
|
379
|
+
data: {
|
380
|
+
index: nextIndex,
|
381
|
+
overflows: overflowsData
|
382
|
+
},
|
383
|
+
reset: {
|
384
|
+
placement: nextPlacement
|
385
|
+
}
|
386
|
+
};
|
387
|
+
}
|
388
|
+
|
389
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
390
|
+
// then find the placement that fits the best on the main crossAxis side.
|
391
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
392
|
+
|
393
|
+
// Otherwise fallback.
|
394
|
+
if (!resetPlacement) {
|
395
|
+
switch (fallbackStrategy) {
|
396
|
+
case 'bestFit':
|
397
|
+
{
|
398
|
+
var _overflowsData$filter2;
|
399
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
400
|
+
if (hasFallbackAxisSideDirection) {
|
401
|
+
const currentSideAxis = floatingUi_utils.getSideAxis(d.placement);
|
402
|
+
return currentSideAxis === initialSideAxis ||
|
403
|
+
// Create a bias to the `y` side axis due to horizontal
|
404
|
+
// reading directions favoring greater width.
|
405
|
+
currentSideAxis === 'y';
|
406
|
+
}
|
407
|
+
return true;
|
408
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
409
|
+
if (placement) {
|
410
|
+
resetPlacement = placement;
|
411
|
+
}
|
412
|
+
break;
|
413
|
+
}
|
414
|
+
case 'initialPlacement':
|
415
|
+
resetPlacement = initialPlacement;
|
416
|
+
break;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
if (placement !== resetPlacement) {
|
420
|
+
return {
|
421
|
+
reset: {
|
422
|
+
placement: resetPlacement
|
423
|
+
}
|
424
|
+
};
|
425
|
+
}
|
426
|
+
}
|
427
|
+
return {};
|
428
|
+
}
|
429
|
+
};
|
430
|
+
};
|
431
|
+
|
432
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
433
|
+
// Derivable.
|
434
|
+
|
435
|
+
async function convertValueToCoords(state, options) {
|
436
|
+
const {
|
437
|
+
placement,
|
438
|
+
platform,
|
439
|
+
elements
|
440
|
+
} = state;
|
441
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
442
|
+
const side = floatingUi_utils.getSide(placement);
|
443
|
+
const alignment = floatingUi_utils.getAlignment(placement);
|
444
|
+
const isVertical = floatingUi_utils.getSideAxis(placement) === 'y';
|
445
|
+
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
446
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
447
|
+
const rawValue = floatingUi_utils.evaluate(options, state);
|
448
|
+
|
449
|
+
// eslint-disable-next-line prefer-const
|
450
|
+
let {
|
451
|
+
mainAxis,
|
452
|
+
crossAxis,
|
453
|
+
alignmentAxis
|
454
|
+
} = typeof rawValue === 'number' ? {
|
455
|
+
mainAxis: rawValue,
|
456
|
+
crossAxis: 0,
|
457
|
+
alignmentAxis: null
|
458
|
+
} : {
|
459
|
+
mainAxis: rawValue.mainAxis || 0,
|
460
|
+
crossAxis: rawValue.crossAxis || 0,
|
461
|
+
alignmentAxis: rawValue.alignmentAxis
|
462
|
+
};
|
463
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
464
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
465
|
+
}
|
466
|
+
return isVertical ? {
|
467
|
+
x: crossAxis * crossAxisMulti,
|
468
|
+
y: mainAxis * mainAxisMulti
|
469
|
+
} : {
|
470
|
+
x: mainAxis * mainAxisMulti,
|
471
|
+
y: crossAxis * crossAxisMulti
|
472
|
+
};
|
473
|
+
}
|
474
|
+
|
475
|
+
/**
|
476
|
+
* Modifies the placement by translating the floating element along the
|
477
|
+
* specified axes.
|
478
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
479
|
+
* object may be passed.
|
480
|
+
* @see https://floating-ui.com/docs/offset
|
481
|
+
*/
|
482
|
+
const offset = function (options) {
|
483
|
+
if (options === void 0) {
|
484
|
+
options = 0;
|
485
|
+
}
|
486
|
+
return {
|
487
|
+
name: 'offset',
|
488
|
+
options,
|
489
|
+
async fn(state) {
|
490
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
491
|
+
const {
|
492
|
+
x,
|
493
|
+
y,
|
494
|
+
placement,
|
495
|
+
middlewareData
|
496
|
+
} = state;
|
497
|
+
const diffCoords = await convertValueToCoords(state, options);
|
498
|
+
|
499
|
+
// If the placement is the same and the arrow caused an alignment offset
|
500
|
+
// then we don't need to change the positioning coordinates.
|
501
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
502
|
+
return {};
|
503
|
+
}
|
504
|
+
return {
|
505
|
+
x: x + diffCoords.x,
|
506
|
+
y: y + diffCoords.y,
|
507
|
+
data: {
|
508
|
+
...diffCoords,
|
509
|
+
placement
|
510
|
+
}
|
511
|
+
};
|
512
|
+
}
|
513
|
+
};
|
514
|
+
};
|
515
|
+
|
516
|
+
/**
|
517
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
518
|
+
* keep it in view when it will overflow the clipping boundary.
|
519
|
+
* @see https://floating-ui.com/docs/shift
|
520
|
+
*/
|
521
|
+
const shift = function (options) {
|
522
|
+
if (options === void 0) {
|
523
|
+
options = {};
|
524
|
+
}
|
525
|
+
return {
|
526
|
+
name: 'shift',
|
527
|
+
options,
|
528
|
+
async fn(state) {
|
529
|
+
const {
|
530
|
+
x,
|
531
|
+
y,
|
532
|
+
placement
|
533
|
+
} = state;
|
534
|
+
const {
|
535
|
+
mainAxis: checkMainAxis = true,
|
536
|
+
crossAxis: checkCrossAxis = false,
|
537
|
+
limiter = {
|
538
|
+
fn: _ref => {
|
539
|
+
let {
|
540
|
+
x,
|
541
|
+
y
|
542
|
+
} = _ref;
|
543
|
+
return {
|
544
|
+
x,
|
545
|
+
y
|
546
|
+
};
|
547
|
+
}
|
548
|
+
},
|
549
|
+
...detectOverflowOptions
|
550
|
+
} = floatingUi_utils.evaluate(options, state);
|
551
|
+
const coords = {
|
552
|
+
x,
|
553
|
+
y
|
554
|
+
};
|
555
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
556
|
+
const crossAxis = floatingUi_utils.getSideAxis(floatingUi_utils.getSide(placement));
|
557
|
+
const mainAxis = floatingUi_utils.getOppositeAxis(crossAxis);
|
558
|
+
let mainAxisCoord = coords[mainAxis];
|
559
|
+
let crossAxisCoord = coords[crossAxis];
|
560
|
+
if (checkMainAxis) {
|
561
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
562
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
563
|
+
const min = mainAxisCoord + overflow[minSide];
|
564
|
+
const max = mainAxisCoord - overflow[maxSide];
|
565
|
+
mainAxisCoord = floatingUi_utils.clamp(min, mainAxisCoord, max);
|
566
|
+
}
|
567
|
+
if (checkCrossAxis) {
|
568
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
569
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
570
|
+
const min = crossAxisCoord + overflow[minSide];
|
571
|
+
const max = crossAxisCoord - overflow[maxSide];
|
572
|
+
crossAxisCoord = floatingUi_utils.clamp(min, crossAxisCoord, max);
|
573
|
+
}
|
574
|
+
const limitedCoords = limiter.fn({
|
575
|
+
...state,
|
576
|
+
[mainAxis]: mainAxisCoord,
|
577
|
+
[crossAxis]: crossAxisCoord
|
578
|
+
});
|
579
|
+
return {
|
580
|
+
...limitedCoords,
|
581
|
+
data: {
|
582
|
+
x: limitedCoords.x - x,
|
583
|
+
y: limitedCoords.y - y,
|
584
|
+
enabled: {
|
585
|
+
[mainAxis]: checkMainAxis,
|
586
|
+
[crossAxis]: checkCrossAxis
|
587
|
+
}
|
588
|
+
}
|
589
|
+
};
|
590
|
+
}
|
591
|
+
};
|
592
|
+
};
|
593
|
+
|
594
|
+
exports.rectToClientRect = floatingUi_utils.rectToClientRect;
|
595
|
+
exports.arrow = arrow;
|
596
|
+
exports.computePosition = computePosition;
|
597
|
+
exports.detectOverflow = detectOverflow;
|
598
|
+
exports.flip = flip;
|
599
|
+
exports.offset = offset;
|
600
|
+
exports.shift = shift;
|