x-ui-design 0.9.11 → 0.9.13
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 +4 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -10
- package/dist/index.js.map +1 -1
- package/lib/hooks/usePopupPosition.ts +5 -12
- package/package.json +1 -1
- package/src/app/page.tsx +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -2653,7 +2653,7 @@ 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 (e?.target && inBody) {
|
|
2656
|
+
if (e?.target === scrollableParents && inBody) {
|
|
2657
2657
|
setOpen(false);
|
|
2658
2658
|
setPopupPosition({});
|
|
2659
2659
|
return;
|
|
@@ -2666,13 +2666,6 @@ const usePopupPosition = ({
|
|
|
2666
2666
|
left: container.left - (popupRect.width + OFFSET),
|
|
2667
2667
|
right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - (container.right + popupRect.width + OFFSET)
|
|
2668
2668
|
};
|
|
2669
|
-
console.log({
|
|
2670
|
-
popupRect,
|
|
2671
|
-
container,
|
|
2672
|
-
scrollableParents,
|
|
2673
|
-
innerWidth: window.innerWidth,
|
|
2674
|
-
innerHeight: window.innerHeight
|
|
2675
|
-
});
|
|
2676
2669
|
let newPlacement = _placement;
|
|
2677
2670
|
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
2678
2671
|
newPlacement = newPlacement.replace('bottom', 'top');
|
|
@@ -2680,10 +2673,10 @@ const usePopupPosition = ({
|
|
|
2680
2673
|
if (availableSpace.top < 0 && availableSpace.bottom > 0) {
|
|
2681
2674
|
newPlacement = newPlacement.replace('top', 'bottom');
|
|
2682
2675
|
}
|
|
2683
|
-
if (availableSpace.left < 0 && availableSpace.right > 0) {
|
|
2676
|
+
if (availableSpace.left < 0 && (availableSpace.right > 0 || availableSpace.right < popupRect.width)) {
|
|
2684
2677
|
newPlacement = newPlacement.replace('Right', 'Left');
|
|
2685
2678
|
}
|
|
2686
|
-
if (availableSpace.right < 0 && availableSpace.left > 0) {
|
|
2679
|
+
if (availableSpace.right < 0 && (availableSpace.left > 0 || availableSpace.left < popupRect.width)) {
|
|
2687
2680
|
newPlacement = newPlacement.replace('Left', 'Right');
|
|
2688
2681
|
}
|
|
2689
2682
|
if (availableSpace.right < 0 && availableSpace.left < 0) {
|
|
@@ -2763,6 +2756,7 @@ const usePopupPosition = ({
|
|
|
2763
2756
|
document.body.addEventListener("resize", calculatePosition, options);
|
|
2764
2757
|
return () => {
|
|
2765
2758
|
controller.abort();
|
|
2759
|
+
setPopupPosition({});
|
|
2766
2760
|
// setPositionRelative('unset');
|
|
2767
2761
|
};
|
|
2768
2762
|
}, [open, targetRef, popupContainer, inBody, calculatePosition]);
|