@ultraviolet/ui 1.51.2 → 1.51.4
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/dist/components/ActionBar/index.cjs +32 -0
- package/dist/components/ActionBar/index.js +16 -26
- package/dist/components/Alert/index.cjs +117 -0
- package/dist/components/Alert/index.js +77 -88
- package/dist/components/Avatar/index.cjs +59 -0
- package/dist/components/Avatar/index.js +29 -26
- package/dist/components/Badge/index.cjs +101 -0
- package/dist/components/Badge/index.js +36 -52
- package/dist/components/Banner/assets/default-image-small.svg.cjs +3 -0
- package/dist/components/Banner/assets/default-image.svg.cjs +3 -0
- package/dist/components/Banner/index.cjs +118 -0
- package/dist/components/Banner/index.js +64 -139
- package/dist/components/BarChart/Tooltip.cjs +42 -0
- package/dist/components/BarChart/Tooltip.js +23 -18
- package/dist/components/BarChart/index.cjs +69 -0
- package/dist/components/BarChart/index.js +29 -42
- package/dist/components/BarStack/index.cjs +116 -0
- package/dist/components/BarStack/index.js +89 -163
- package/dist/components/Breadcrumbs/index.cjs +75 -0
- package/dist/components/Breadcrumbs/index.js +30 -33
- package/dist/components/Bullet/index.cjs +86 -0
- package/dist/components/Bullet/index.js +24 -28
- package/dist/components/Button/index.cjs +251 -0
- package/dist/components/Button/index.js +117 -159
- package/dist/components/Card/index.cjs +54 -0
- package/dist/components/Card/index.js +45 -52
- package/dist/components/Carousel/index.cjs +125 -0
- package/dist/components/Carousel/index.js +75 -99
- package/dist/components/Checkbox/index.cjs +264 -0
- package/dist/components/Checkbox/index.js +246 -343
- package/dist/components/CheckboxGroup/index.cjs +118 -0
- package/dist/components/CheckboxGroup/index.js +60 -56
- package/dist/components/CopyButton/index.cjs +25 -0
- package/dist/components/CopyButton/index.js +1 -15
- package/dist/components/DateInput/datepicker.css.cjs +3 -0
- package/dist/components/DateInput/index.cjs +185 -0
- package/dist/components/DateInput/index.js +124 -243
- package/dist/components/Dialog/Context.cjs +13 -0
- package/dist/components/Dialog/Context.js +1 -3
- package/dist/components/Dialog/index.cjs +68 -0
- package/dist/components/Dialog/index.js +22 -43
- package/dist/components/Dialog/subComponents/Button.cjs +15 -0
- package/dist/components/Dialog/subComponents/Button.js +1 -10
- package/dist/components/Dialog/subComponents/Buttons.cjs +12 -0
- package/dist/components/Dialog/subComponents/CancelButton.cjs +9 -0
- package/dist/components/Dialog/subComponents/Stack.cjs +8 -0
- package/dist/components/Dialog/subComponents/Stack.js +3 -1
- package/dist/components/Dialog/subComponents/Text.cjs +8 -0
- package/dist/components/Dialog/subComponents/Text.js +3 -1
- package/dist/components/EmptyState/index.cjs +92 -0
- package/dist/components/EmptyState/index.js +58 -50
- package/dist/components/Expandable/index.cjs +77 -0
- package/dist/components/Expandable/index.js +19 -23
- package/dist/components/GlobalAlert/GlobalAlertLink.cjs +23 -0
- package/dist/components/GlobalAlert/GlobalAlertLink.js +4 -20
- package/dist/components/GlobalAlert/index.cjs +61 -0
- package/dist/components/GlobalAlert/index.js +34 -87
- package/dist/components/LineChart/CustomLegend.cjs +115 -0
- package/dist/components/LineChart/CustomLegend.js +76 -72
- package/dist/components/LineChart/Tooltip.cjs +37 -0
- package/dist/components/LineChart/Tooltip.js +26 -37
- package/dist/components/LineChart/helpers.cjs +52 -0
- package/dist/components/LineChart/helpers.js +11 -9
- package/dist/components/LineChart/index.cjs +101 -0
- package/dist/components/LineChart/index.js +38 -55
- package/dist/components/Link/index.cjs +130 -0
- package/dist/components/Link/index.js +86 -125
- package/dist/components/List/Body.cjs +18 -0
- package/dist/components/List/Body.js +12 -7
- package/dist/components/List/Cell.cjs +43 -0
- package/dist/components/List/Cell.js +36 -33
- package/dist/components/List/HeaderCell.cjs +84 -0
- package/dist/components/List/HeaderCell.js +54 -68
- package/dist/components/List/HeaderRow.cjs +38 -0
- package/dist/components/List/HeaderRow.js +16 -18
- package/dist/components/List/ListContext.cjs +136 -0
- package/dist/components/List/ListContext.js +68 -87
- package/dist/components/List/Row.cjs +163 -0
- package/dist/components/List/Row.js +136 -169
- package/dist/components/List/SelectBar.cjs +54 -0
- package/dist/components/List/SelectBar.js +31 -14
- package/dist/components/List/SkeletonRows.cjs +57 -0
- package/dist/components/List/SkeletonRows.js +42 -23
- package/dist/components/List/constants.cjs +6 -0
- package/dist/components/List/index.cjs +62 -0
- package/dist/components/List/index.js +39 -59
- package/dist/components/Loader/index.cjs +79 -0
- package/dist/components/Loader/index.js +44 -65
- package/dist/components/Menu/Item.cjs +92 -0
- package/dist/components/Menu/Item.js +52 -62
- package/dist/components/Menu/index.cjs +118 -0
- package/dist/components/Menu/index.js +105 -171
- package/dist/components/MenuV2/Group.cjs +23 -0
- package/dist/components/MenuV2/Group.js +14 -16
- package/dist/components/MenuV2/Item.cjs +114 -0
- package/dist/components/MenuV2/Item.js +67 -74
- package/dist/components/MenuV2/index.cjs +92 -0
- package/dist/components/MenuV2/index.js +76 -110
- package/dist/components/Meter/index.cjs +65 -0
- package/dist/components/Meter/index.js +44 -57
- package/dist/components/Modal/Dialog.cjs +143 -0
- package/dist/components/Modal/Dialog.js +44 -100
- package/dist/components/Modal/Disclosure.cjs +44 -0
- package/dist/components/Modal/constants.cjs +52 -0
- package/dist/components/Modal/index.cjs +81 -0
- package/dist/components/Modal/index.js +23 -58
- package/dist/components/Notice/index.cjs +25 -0
- package/dist/components/Notice/index.js +13 -29
- package/dist/components/Notification/index.cjs +49 -0
- package/dist/components/Notification/index.js +9 -48
- package/dist/components/Notification/react-toastify.css.cjs +3 -0
- package/dist/components/NumberInput/helpers.cjs +10 -0
- package/dist/components/NumberInput/index.cjs +264 -0
- package/dist/components/NumberInput/index.js +113 -200
- package/dist/components/NumberInputV2/index.cjs +223 -0
- package/dist/components/NumberInputV2/index.js +200 -349
- package/dist/components/Pagination/getPageNumbers.cjs +23 -0
- package/dist/components/Pagination/getPageNumbers.js +3 -1
- package/dist/components/Pagination/index.cjs +90 -0
- package/dist/components/Pagination/index.js +45 -81
- package/dist/components/PasswordCheck/index.cjs +26 -0
- package/dist/components/PasswordCheck/index.js +10 -15
- package/dist/components/PasswordStrengthMeter/index.cjs +98 -0
- package/dist/components/PasswordStrengthMeter/index.js +66 -68
- package/dist/components/PieChart/Legends.cjs +143 -0
- package/dist/components/PieChart/Legends.js +121 -99
- package/dist/components/PieChart/Tooltip.cjs +50 -0
- package/dist/components/PieChart/Tooltip.js +35 -15
- package/dist/components/PieChart/index.cjs +103 -0
- package/dist/components/PieChart/index.js +68 -87
- package/dist/components/Popover/index.cjs +102 -0
- package/dist/components/Popover/index.js +57 -106
- package/dist/components/Popup/animations.cjs +25 -0
- package/dist/components/Popup/helpers.cjs +216 -0
- package/dist/components/Popup/helpers.js +24 -12
- package/dist/components/Popup/index.cjs +299 -0
- package/dist/components/Popup/index.js +263 -351
- package/dist/components/ProgressBar/index.cjs +55 -0
- package/dist/components/ProgressBar/index.js +33 -51
- package/dist/components/Radio/index.cjs +135 -0
- package/dist/components/Radio/index.js +119 -188
- package/dist/components/RadioGroup/index.cjs +101 -0
- package/dist/components/RadioGroup/index.js +46 -51
- package/dist/components/Row/index.cjs +36 -0
- package/dist/components/Row/index.js +11 -20
- package/dist/components/SelectInput/index.cjs +520 -0
- package/dist/components/SelectInput/index.js +165 -212
- package/dist/components/SelectInputV2/Dropdown.cjs +431 -0
- package/dist/components/SelectInputV2/Dropdown.js +233 -473
- package/dist/components/SelectInputV2/DropdownOption.cjs +64 -0
- package/dist/components/SelectInputV2/DropdownOption.js +44 -115
- package/dist/components/SelectInputV2/SearchBarDropdown.cjs +109 -0
- package/dist/components/SelectInputV2/SearchBarDropdown.js +28 -44
- package/dist/components/SelectInputV2/SelectBar.cjs +226 -0
- package/dist/components/SelectInputV2/SelectBar.js +137 -240
- package/dist/components/SelectInputV2/SelectInputProvider.cjs +171 -0
- package/dist/components/SelectInputV2/SelectInputProvider.js +45 -77
- package/dist/components/SelectInputV2/findOptionInOptions.cjs +12 -0
- package/dist/components/SelectInputV2/index.cjs +89 -0
- package/dist/components/SelectInputV2/index.js +39 -98
- package/dist/components/SelectInputV2/types.cjs +13 -0
- package/dist/components/SelectableCard/index.cjs +139 -0
- package/dist/components/SelectableCard/index.js +127 -183
- package/dist/components/SelectableCardGroup/index.cjs +109 -0
- package/dist/components/SelectableCardGroup/index.js +50 -55
- package/dist/components/Separator/index.cjs +58 -0
- package/dist/components/Separator/index.js +44 -64
- package/dist/components/Skeleton/Block.cjs +40 -0
- package/dist/components/Skeleton/Block.js +28 -20
- package/dist/components/Skeleton/Blocks.cjs +40 -0
- package/dist/components/Skeleton/Blocks.js +26 -16
- package/dist/components/Skeleton/BoxWithIcon.cjs +38 -0
- package/dist/components/Skeleton/BoxWithIcon.js +24 -17
- package/dist/components/Skeleton/Donut.cjs +63 -0
- package/dist/components/Skeleton/Donut.js +46 -21
- package/dist/components/Skeleton/IconSkeleton.cjs +24 -0
- package/dist/components/Skeleton/IconSkeleton.js +19 -9
- package/dist/components/Skeleton/Line.cjs +18 -0
- package/dist/components/Skeleton/Line.js +11 -8
- package/dist/components/Skeleton/List.cjs +58 -0
- package/dist/components/Skeleton/List.js +48 -21
- package/dist/components/Skeleton/Slider.cjs +42 -0
- package/dist/components/Skeleton/Slider.js +36 -22
- package/dist/components/Skeleton/Square.cjs +14 -0
- package/dist/components/Skeleton/Square.js +9 -7
- package/dist/components/Skeleton/index.cjs +81 -0
- package/dist/components/Skeleton/index.js +38 -45
- package/dist/components/Snippet/index.cjs +184 -0
- package/dist/components/Snippet/index.js +139 -128
- package/dist/components/Stack/index.cjs +31 -0
- package/dist/components/Stack/index.js +10 -17
- package/dist/components/Status/index.cjs +74 -0
- package/dist/components/Status/index.js +42 -27
- package/dist/components/StepList/index.cjs +60 -0
- package/dist/components/StepList/index.js +34 -45
- package/dist/components/Stepper/index.cjs +147 -0
- package/dist/components/Stepper/index.js +106 -114
- package/dist/components/SwitchButton/FocusOverlay.cjs +40 -0
- package/dist/components/SwitchButton/FocusOverlay.js +18 -27
- package/dist/components/SwitchButton/index.cjs +78 -0
- package/dist/components/SwitchButton/index.js +39 -103
- package/dist/components/Table/Body.cjs +7 -0
- package/dist/components/Table/Body.js +3 -1
- package/dist/components/Table/Cell.cjs +21 -0
- package/dist/components/Table/Cell.js +15 -6
- package/dist/components/Table/Header.cjs +18 -0
- package/dist/components/Table/Header.js +12 -5
- package/dist/components/Table/HeaderCell.cjs +82 -0
- package/dist/components/Table/HeaderCell.js +48 -91
- package/dist/components/Table/HeaderRow.cjs +23 -0
- package/dist/components/Table/HeaderRow.js +11 -13
- package/dist/components/Table/Row.cjs +82 -0
- package/dist/components/Table/Row.js +39 -44
- package/dist/components/Table/SelectBar.cjs +54 -0
- package/dist/components/Table/SelectBar.js +31 -14
- package/dist/components/Table/SkeletonRows.cjs +56 -0
- package/dist/components/Table/SkeletonRows.js +43 -11
- package/dist/components/Table/TableContext.cjs +88 -0
- package/dist/components/Table/TableContext.js +29 -44
- package/dist/components/Table/index.cjs +69 -0
- package/dist/components/Table/index.js +37 -51
- package/dist/components/Tabs/Tab.cjs +122 -0
- package/dist/components/Tabs/Tab.js +108 -158
- package/dist/components/Tabs/TabMenu.cjs +64 -0
- package/dist/components/Tabs/TabMenu.js +52 -53
- package/dist/components/Tabs/TabMenuItem.cjs +36 -0
- package/dist/components/Tabs/TabMenuItem.js +19 -24
- package/dist/components/Tabs/TabsContext.cjs +7 -0
- package/dist/components/Tabs/TabsContext.js +1 -3
- package/dist/components/Tabs/index.cjs +104 -0
- package/dist/components/Tabs/index.js +44 -79
- package/dist/components/Tag/index.cjs +147 -0
- package/dist/components/Tag/index.js +66 -75
- package/dist/components/TagInput/index.cjs +255 -0
- package/dist/components/TagInput/index.js +125 -188
- package/dist/components/TagList/index.cjs +100 -0
- package/dist/components/TagList/index.js +51 -56
- package/dist/components/Text/index.cjs +84 -0
- package/dist/components/Text/index.js +10 -35
- package/dist/components/TextArea/index.cjs +160 -0
- package/dist/components/TextArea/index.js +140 -208
- package/dist/components/TextInput/index.cjs +390 -0
- package/dist/components/TextInput/index.js +326 -411
- package/dist/components/TextInputV2/index.cjs +192 -0
- package/dist/components/TextInputV2/index.js +170 -294
- package/dist/components/TimeInput/index.cjs +28 -0
- package/dist/components/TimeInput/index.js +3 -174
- package/dist/components/Toaster/index.cjs +85 -0
- package/dist/components/Toaster/index.js +26 -74
- package/dist/components/Toaster/react-toastify.css.cjs +3 -0
- package/dist/components/Toggle/index.cjs +138 -0
- package/dist/components/Toggle/index.js +112 -172
- package/dist/components/ToggleGroup/index.cjs +98 -0
- package/dist/components/ToggleGroup/index.js +44 -35
- package/dist/components/Tooltip/index.cjs +42 -0
- package/dist/components/Tooltip/index.js +34 -41
- package/dist/components/VerificationCode/index.cjs +219 -0
- package/dist/components/VerificationCode/index.js +58 -63
- package/dist/helpers/isJSON.cjs +10 -0
- package/dist/helpers/legend.cjs +14 -0
- package/dist/helpers/legend.js +4 -4
- package/dist/helpers/recursivelyGetChildrenString.cjs +14 -0
- package/dist/hooks/useIsOverflowing.cjs +23 -0
- package/dist/index.cjs +196 -0
- package/dist/theme/index.cjs +34 -0
- package/dist/theme/index.js +10 -13
- package/dist/utils/animations.cjs +276 -0
- package/dist/utils/capitalize.cjs +3 -0
- package/dist/utils/ids.cjs +8 -0
- package/dist/utils/ids.js +3 -1
- package/dist/utils/normalize.cjs +36 -0
- package/dist/utils/responsive/Breakpoint.cjs +16 -0
- package/dist/utils/responsive/Breakpoint.js +8 -6
- package/dist/utils/responsive/utilities.cjs +15 -0
- package/package.json +23 -7
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ARROW_WIDTH = 8;
|
|
4
|
+
const SPACE = 4;
|
|
5
|
+
const TOTAL_USED_SPACE = 0;
|
|
6
|
+
const DEFAULT_POSITIONS = {
|
|
7
|
+
arrowLeft: 0,
|
|
8
|
+
arrowTop: 0,
|
|
9
|
+
arrowTransform: "translate(-50%, -50)",
|
|
10
|
+
placement: "top",
|
|
11
|
+
rotate: 135,
|
|
12
|
+
popupInitialPosition: "translate3d(0px, 0px, 0)",
|
|
13
|
+
popupPosition: "translate3d(0px, 0px, 0)"
|
|
14
|
+
};
|
|
15
|
+
const computePlacement = ({
|
|
16
|
+
childrenStructuredRef,
|
|
17
|
+
popupStructuredRef,
|
|
18
|
+
offsetParentRect,
|
|
19
|
+
offsetParent,
|
|
20
|
+
popupPortalTarget
|
|
21
|
+
}) => {
|
|
22
|
+
const {
|
|
23
|
+
top: childrenTop,
|
|
24
|
+
left: childrenLeft,
|
|
25
|
+
right: childrenRight,
|
|
26
|
+
width: childrenWidth
|
|
27
|
+
} = childrenStructuredRef;
|
|
28
|
+
const {
|
|
29
|
+
top: parentTop,
|
|
30
|
+
left: parentLeft
|
|
31
|
+
} = offsetParentRect;
|
|
32
|
+
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
33
|
+
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
34
|
+
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
35
|
+
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
|
|
36
|
+
const {
|
|
37
|
+
width: popupWidth,
|
|
38
|
+
height: popupHeight
|
|
39
|
+
} = popupStructuredRef;
|
|
40
|
+
if (overloadedChildrenTop - popupHeight - TOTAL_USED_SPACE < 0) {
|
|
41
|
+
return "bottom";
|
|
42
|
+
}
|
|
43
|
+
if (overloadedChildrenLeft - popupWidth - TOTAL_USED_SPACE < 0) {
|
|
44
|
+
return "right";
|
|
45
|
+
}
|
|
46
|
+
if (overloadedChildrenRight + popupWidth + TOTAL_USED_SPACE > window.innerWidth) {
|
|
47
|
+
return "left";
|
|
48
|
+
}
|
|
49
|
+
return "top";
|
|
50
|
+
};
|
|
51
|
+
const findOffsetParent = (element) => {
|
|
52
|
+
const offsetParent = element?.current?.offsetParent;
|
|
53
|
+
if (offsetParent && !["TH", "TD", "TABLE"].includes(offsetParent.tagName)) {
|
|
54
|
+
return offsetParent;
|
|
55
|
+
}
|
|
56
|
+
let currentElement = element?.current;
|
|
57
|
+
while (currentElement && currentElement.tagName !== "BODY") {
|
|
58
|
+
const {
|
|
59
|
+
position
|
|
60
|
+
} = window.getComputedStyle(currentElement);
|
|
61
|
+
if (position !== "static") {
|
|
62
|
+
return currentElement;
|
|
63
|
+
}
|
|
64
|
+
currentElement = currentElement.parentElement;
|
|
65
|
+
}
|
|
66
|
+
return document.body;
|
|
67
|
+
};
|
|
68
|
+
const getPopupOverflowFromParent = (position, offsetParentRect, childrenRect, popupStructuredRef) => {
|
|
69
|
+
const {
|
|
70
|
+
top: parentTop,
|
|
71
|
+
left: parentLeft,
|
|
72
|
+
right: parentRight
|
|
73
|
+
} = offsetParentRect;
|
|
74
|
+
const {
|
|
75
|
+
top: childrenTop,
|
|
76
|
+
bottom: childrenBottom,
|
|
77
|
+
left: childrenLeft,
|
|
78
|
+
right: childrenRight,
|
|
79
|
+
width: childrenWidth
|
|
80
|
+
} = childrenRect;
|
|
81
|
+
const {
|
|
82
|
+
width: popupWidth,
|
|
83
|
+
height: popupHeight
|
|
84
|
+
} = popupStructuredRef;
|
|
85
|
+
const popupHalfWidthWithArrow = popupWidth / 2 - ARROW_WIDTH;
|
|
86
|
+
const popupHalfHeightWithArrow = popupHeight / 2 - ARROW_WIDTH;
|
|
87
|
+
if (position === "top" || position === "bottom") {
|
|
88
|
+
const popupOverflowRight = childrenRight - childrenWidth / 2 + popupWidth / 2;
|
|
89
|
+
const popupOverflowLeft = childrenLeft + childrenWidth / 2 - parentLeft - popupWidth / 2;
|
|
90
|
+
if (popupOverflowRight > parentRight) {
|
|
91
|
+
if (Math.abs(popupOverflowRight - parentRight) > popupHalfWidthWithArrow) {
|
|
92
|
+
return -popupHalfWidthWithArrow;
|
|
93
|
+
}
|
|
94
|
+
return parentRight - popupOverflowRight;
|
|
95
|
+
}
|
|
96
|
+
if (popupOverflowLeft < 0) {
|
|
97
|
+
if (Math.abs(popupOverflowLeft) > popupHalfWidthWithArrow) {
|
|
98
|
+
return popupHalfWidthWithArrow;
|
|
99
|
+
}
|
|
100
|
+
return Math.abs(popupOverflowLeft);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (position === "left" || position === "right") {
|
|
104
|
+
const popupOverflowTop = childrenTop - parentTop - popupHeight / 2;
|
|
105
|
+
if (popupOverflowTop < 0) {
|
|
106
|
+
if (Math.abs(childrenTop - parentTop - popupHalfHeightWithArrow) > popupHalfHeightWithArrow) {
|
|
107
|
+
return popupHalfHeightWithArrow;
|
|
108
|
+
}
|
|
109
|
+
return Math.abs(popupOverflowTop);
|
|
110
|
+
}
|
|
111
|
+
if (childrenBottom + popupHeight > window.innerHeight) {
|
|
112
|
+
return -popupHalfHeightWithArrow;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return 0;
|
|
116
|
+
};
|
|
117
|
+
const computePositions = ({
|
|
118
|
+
placement,
|
|
119
|
+
childrenRef,
|
|
120
|
+
popupRef,
|
|
121
|
+
popupPortalTarget
|
|
122
|
+
}) => {
|
|
123
|
+
const childrenRect = childrenRef.current.getBoundingClientRect();
|
|
124
|
+
const offsetParent = findOffsetParent(childrenRef);
|
|
125
|
+
const offsetParentRect = offsetParent?.getBoundingClientRect() ?? {
|
|
126
|
+
top: 0,
|
|
127
|
+
left: 0,
|
|
128
|
+
right: 0
|
|
129
|
+
};
|
|
130
|
+
const popupStructuredRef = popupRef.current.getBoundingClientRect();
|
|
131
|
+
const placementBasedOnWindowSize = placement === "auto" ? computePlacement({
|
|
132
|
+
childrenStructuredRef: childrenRect,
|
|
133
|
+
popupStructuredRef,
|
|
134
|
+
offsetParentRect,
|
|
135
|
+
popupPortalTarget,
|
|
136
|
+
offsetParent
|
|
137
|
+
}) : placement;
|
|
138
|
+
const {
|
|
139
|
+
top: childrenTop,
|
|
140
|
+
left: childrenLeft,
|
|
141
|
+
right: childrenRight,
|
|
142
|
+
width: childrenWidth,
|
|
143
|
+
height: childrenHeight
|
|
144
|
+
} = childrenRect;
|
|
145
|
+
const {
|
|
146
|
+
top: parentTop,
|
|
147
|
+
left: parentLeft
|
|
148
|
+
} = offsetParentRect;
|
|
149
|
+
const {
|
|
150
|
+
width: popupWidth,
|
|
151
|
+
height: popupHeight
|
|
152
|
+
} = popupStructuredRef;
|
|
153
|
+
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
154
|
+
const scrollTopValue = isPopupPortalTargetBody ? document.documentElement.scrollTop : offsetParent.scrollTop;
|
|
155
|
+
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
156
|
+
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
157
|
+
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
|
|
158
|
+
const popupOverflow = getPopupOverflowFromParent(placementBasedOnWindowSize, offsetParentRect, childrenRect, popupStructuredRef);
|
|
159
|
+
switch (placementBasedOnWindowSize) {
|
|
160
|
+
case "bottom": {
|
|
161
|
+
const positionX = overloadedChildrenLeft + childrenWidth / 2 - popupWidth / 2;
|
|
162
|
+
const positionY = overloadedChildrenTop + scrollTopValue + childrenHeight + ARROW_WIDTH + SPACE;
|
|
163
|
+
return {
|
|
164
|
+
arrowLeft: popupWidth / 2 + popupOverflow * -1,
|
|
165
|
+
arrowTop: -ARROW_WIDTH - 5,
|
|
166
|
+
arrowTransform: "",
|
|
167
|
+
placement: "bottom",
|
|
168
|
+
rotate: 180,
|
|
169
|
+
popupInitialPosition: `translate3d(${positionX + popupOverflow}px, ${positionY - TOTAL_USED_SPACE}px, 0)`,
|
|
170
|
+
popupPosition: `translate3d(${positionX + popupOverflow}px, ${positionY}px, 0)`
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
case "left": {
|
|
174
|
+
const positionX = overloadedChildrenLeft - popupWidth - ARROW_WIDTH - SPACE * 2;
|
|
175
|
+
const positionY = overloadedChildrenTop + scrollTopValue - popupHeight / 2 + childrenHeight / 2;
|
|
176
|
+
return {
|
|
177
|
+
arrowLeft: popupWidth + ARROW_WIDTH + 5,
|
|
178
|
+
arrowTop: popupHeight / 2 + popupOverflow * -1,
|
|
179
|
+
arrowTransform: "translate(-50%, -50%)",
|
|
180
|
+
placement: "left",
|
|
181
|
+
rotate: -90,
|
|
182
|
+
popupInitialPosition: `translate3d(${positionX + TOTAL_USED_SPACE}px, ${positionY + popupOverflow}px, 0)`,
|
|
183
|
+
popupPosition: `translate3d(${positionX}px, ${positionY + popupOverflow}px, 0)`
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
case "right": {
|
|
187
|
+
const positionX = overloadedChildrenRight + ARROW_WIDTH + SPACE * 2;
|
|
188
|
+
const positionY = overloadedChildrenTop + scrollTopValue - popupHeight / 2 + childrenHeight / 2;
|
|
189
|
+
return {
|
|
190
|
+
arrowLeft: -ARROW_WIDTH - 5,
|
|
191
|
+
arrowTop: popupHeight / 2 + popupOverflow * -1,
|
|
192
|
+
arrowTransform: "translate(50%, -50%)",
|
|
193
|
+
placement: "right",
|
|
194
|
+
rotate: 90,
|
|
195
|
+
popupInitialPosition: `translate3d(${positionX - TOTAL_USED_SPACE}px, ${positionY + popupOverflow}px, 0)`,
|
|
196
|
+
popupPosition: `translate3d(${positionX}px, ${positionY + popupOverflow}px, 0)`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
default: {
|
|
200
|
+
const positionX = overloadedChildrenLeft + childrenWidth / 2 - popupWidth / 2;
|
|
201
|
+
const positionY = overloadedChildrenTop + scrollTopValue - popupHeight - ARROW_WIDTH - SPACE;
|
|
202
|
+
return {
|
|
203
|
+
arrowLeft: popupWidth / 2 + popupOverflow * -1,
|
|
204
|
+
arrowTop: popupHeight - 1,
|
|
205
|
+
arrowTransform: "",
|
|
206
|
+
placement: "top",
|
|
207
|
+
rotate: 0,
|
|
208
|
+
popupInitialPosition: `translate3d(${positionX + popupOverflow}px, ${positionY + TOTAL_USED_SPACE}px, 0)`,
|
|
209
|
+
popupPosition: `translate3d(${positionX + popupOverflow}px, ${positionY}px, 0)`
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
exports.ARROW_WIDTH = ARROW_WIDTH;
|
|
215
|
+
exports.DEFAULT_POSITIONS = DEFAULT_POSITIONS;
|
|
216
|
+
exports.computePositions = computePositions;
|
|
@@ -23,12 +23,18 @@ const computePlacement = ({
|
|
|
23
23
|
right: childrenRight,
|
|
24
24
|
width: childrenWidth
|
|
25
25
|
} = childrenStructuredRef;
|
|
26
|
-
const {
|
|
26
|
+
const {
|
|
27
|
+
top: parentTop,
|
|
28
|
+
left: parentLeft
|
|
29
|
+
} = offsetParentRect;
|
|
27
30
|
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
28
31
|
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
29
32
|
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
30
33
|
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
|
|
31
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
width: popupWidth,
|
|
36
|
+
height: popupHeight
|
|
37
|
+
} = popupStructuredRef;
|
|
32
38
|
if (overloadedChildrenTop - popupHeight - TOTAL_USED_SPACE < 0) {
|
|
33
39
|
return "bottom";
|
|
34
40
|
}
|
|
@@ -47,7 +53,9 @@ const findOffsetParent = (element) => {
|
|
|
47
53
|
}
|
|
48
54
|
let currentElement = element?.current;
|
|
49
55
|
while (currentElement && currentElement.tagName !== "BODY") {
|
|
50
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
position
|
|
58
|
+
} = window.getComputedStyle(currentElement);
|
|
51
59
|
if (position !== "static") {
|
|
52
60
|
return currentElement;
|
|
53
61
|
}
|
|
@@ -68,7 +76,10 @@ const getPopupOverflowFromParent = (position, offsetParentRect, childrenRect, po
|
|
|
68
76
|
right: childrenRight,
|
|
69
77
|
width: childrenWidth
|
|
70
78
|
} = childrenRect;
|
|
71
|
-
const {
|
|
79
|
+
const {
|
|
80
|
+
width: popupWidth,
|
|
81
|
+
height: popupHeight
|
|
82
|
+
} = popupStructuredRef;
|
|
72
83
|
const popupHalfWidthWithArrow = popupWidth / 2 - ARROW_WIDTH;
|
|
73
84
|
const popupHalfHeightWithArrow = popupHeight / 2 - ARROW_WIDTH;
|
|
74
85
|
if (position === "top" || position === "bottom") {
|
|
@@ -129,19 +140,20 @@ const computePositions = ({
|
|
|
129
140
|
width: childrenWidth,
|
|
130
141
|
height: childrenHeight
|
|
131
142
|
} = childrenRect;
|
|
132
|
-
const {
|
|
133
|
-
|
|
143
|
+
const {
|
|
144
|
+
top: parentTop,
|
|
145
|
+
left: parentLeft
|
|
146
|
+
} = offsetParentRect;
|
|
147
|
+
const {
|
|
148
|
+
width: popupWidth,
|
|
149
|
+
height: popupHeight
|
|
150
|
+
} = popupStructuredRef;
|
|
134
151
|
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
135
152
|
const scrollTopValue = isPopupPortalTargetBody ? document.documentElement.scrollTop : offsetParent.scrollTop;
|
|
136
153
|
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
137
154
|
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
138
155
|
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
|
|
139
|
-
const popupOverflow = getPopupOverflowFromParent(
|
|
140
|
-
placementBasedOnWindowSize,
|
|
141
|
-
offsetParentRect,
|
|
142
|
-
childrenRect,
|
|
143
|
-
popupStructuredRef
|
|
144
|
-
);
|
|
156
|
+
const popupOverflow = getPopupOverflowFromParent(placementBasedOnWindowSize, offsetParentRect, childrenRect, popupStructuredRef);
|
|
145
157
|
switch (placementBasedOnWindowSize) {
|
|
146
158
|
case "bottom": {
|
|
147
159
|
const positionX = overloadedChildrenLeft + childrenWidth / 2 - popupWidth / 2;
|