x-ui-design 0.8.92 → 0.8.94
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 +14 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/lib/hooks/usePopupPosition.ts +16 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2653,13 +2653,13 @@ const usePopupPosition = ({
|
|
|
2653
2653
|
top: (relativePosition.top || 0) + (targetRef.current?.offsetTop || 0) - (scrollableParents?.offsetTop || 0) + OFFSET,
|
|
2654
2654
|
left: relativePosition.left + (targetRef.current?.offsetLeft || 0) - (targetRef.current?.clientWidth || 0) / 2
|
|
2655
2655
|
};
|
|
2656
|
-
if (
|
|
2656
|
+
if (popupRef.current) {
|
|
2657
2657
|
const popupRect = popupRef.current.getBoundingClientRect();
|
|
2658
2658
|
const availableSpace = {
|
|
2659
2659
|
top: container.top - (popupRect.height + OFFSET),
|
|
2660
2660
|
bottom: (scrollableParents?.clientHeight || 0) - (container.bottom + popupRect.height + OFFSET),
|
|
2661
2661
|
left: container.left - (popupRect.width + OFFSET),
|
|
2662
|
-
right: (scrollableParents?.clientWidth || 0) - (container.right + popupRect.width + OFFSET)
|
|
2662
|
+
right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - (container.right + popupRect.width + OFFSET)
|
|
2663
2663
|
};
|
|
2664
2664
|
let newPlacement = _placement;
|
|
2665
2665
|
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
@@ -2674,6 +2674,18 @@ const usePopupPosition = ({
|
|
|
2674
2674
|
if (availableSpace.right < 0 && availableSpace.left > 0) {
|
|
2675
2675
|
newPlacement = newPlacement.replace('Left', 'Right');
|
|
2676
2676
|
}
|
|
2677
|
+
console.info({
|
|
2678
|
+
availableSpace,
|
|
2679
|
+
inBody
|
|
2680
|
+
});
|
|
2681
|
+
if (availableSpace.right < 0 && availableSpace.left < 0) {
|
|
2682
|
+
if (newPlacement.includes('Right')) {
|
|
2683
|
+
positions.left = popupRef.current.clientWidth - positions.left + container.left;
|
|
2684
|
+
}
|
|
2685
|
+
if (newPlacement.includes('Left')) {
|
|
2686
|
+
positions.left = positions.left - popupRef.current.clientWidth + container.width;
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2677
2689
|
_setPlacement(newPlacement);
|
|
2678
2690
|
}
|
|
2679
2691
|
if (e?.target === scrollableParents && inBody) {
|