x-ui-design 0.9.35 → 0.9.36
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/index.esm.js +9 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/lib/helpers/index.ts +20 -15
- package/lib/hooks/usePopupPosition.ts +2 -2
- package/package.json +1 -1
- package/src/app/page.tsx +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1639,14 +1639,17 @@ function getElementParentDetails(el, includeSelf = false) {
|
|
|
1639
1639
|
left: 0,
|
|
1640
1640
|
top: 0
|
|
1641
1641
|
};
|
|
1642
|
+
function hasActualScroll(element) {
|
|
1643
|
+
return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
|
|
1644
|
+
}
|
|
1642
1645
|
while (current) {
|
|
1643
1646
|
const style = getComputedStyle(current);
|
|
1644
|
-
const
|
|
1645
|
-
if (current.style.position ===
|
|
1647
|
+
const allowScroll = style.overflowY !== "visible" || style.overflowX !== "visible";
|
|
1648
|
+
if (current.style.position === "relative") {
|
|
1646
1649
|
relativePosition.left += current.offsetLeft;
|
|
1647
1650
|
relativePosition.top += current.offsetTop;
|
|
1648
1651
|
}
|
|
1649
|
-
if (
|
|
1652
|
+
if (allowScroll && hasActualScroll(current)) {
|
|
1650
1653
|
return {
|
|
1651
1654
|
relativePosition,
|
|
1652
1655
|
scrollableParents: current
|
|
@@ -1655,10 +1658,7 @@ function getElementParentDetails(el, includeSelf = false) {
|
|
|
1655
1658
|
current = current.parentElement;
|
|
1656
1659
|
}
|
|
1657
1660
|
return {
|
|
1658
|
-
relativePosition
|
|
1659
|
-
left: 0,
|
|
1660
|
-
top: 0
|
|
1661
|
-
},
|
|
1661
|
+
relativePosition,
|
|
1662
1662
|
scrollableParents: document.scrollingElement
|
|
1663
1663
|
};
|
|
1664
1664
|
}
|
|
@@ -2676,9 +2676,9 @@ const usePopupPosition = ({
|
|
|
2676
2676
|
right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - ((targetRef.current?.offsetLeft || 0 || container.right) + popupRect.width + OFFSET)
|
|
2677
2677
|
};
|
|
2678
2678
|
let newPlacement = _placement;
|
|
2679
|
-
if (availableSpace.bottom < 0 && availableSpace.top > 0
|
|
2679
|
+
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
2680
2680
|
newPlacement = newPlacement.replace('bottom', 'top');
|
|
2681
|
-
} else if (availableSpace.top < 0 && availableSpace.bottom > 0
|
|
2681
|
+
} else if (availableSpace.top < 0 && availableSpace.bottom > 0) {
|
|
2682
2682
|
newPlacement = newPlacement.replace('top', 'bottom');
|
|
2683
2683
|
}
|
|
2684
2684
|
if (availableSpace.left < 0 && availableSpace.right > 0 && availableSpace.right > popupRect.width) {
|