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.js
CHANGED
|
@@ -2655,7 +2655,7 @@ const usePopupPosition = ({
|
|
|
2655
2655
|
top: (relativePosition.top || 0) + (targetRef.current?.offsetTop || 0) - (scrollableParents?.offsetTop || 0) + OFFSET,
|
|
2656
2656
|
left: relativePosition.left + (targetRef.current?.offsetLeft || 0) - (targetRef.current?.clientWidth || 0) / 2
|
|
2657
2657
|
};
|
|
2658
|
-
if (e?.target && inBody) {
|
|
2658
|
+
if (e?.target === scrollableParents && inBody) {
|
|
2659
2659
|
setOpen(false);
|
|
2660
2660
|
setPopupPosition({});
|
|
2661
2661
|
return;
|
|
@@ -2668,13 +2668,6 @@ const usePopupPosition = ({
|
|
|
2668
2668
|
left: container.left - (popupRect.width + OFFSET),
|
|
2669
2669
|
right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - (container.right + popupRect.width + OFFSET)
|
|
2670
2670
|
};
|
|
2671
|
-
console.log({
|
|
2672
|
-
popupRect,
|
|
2673
|
-
container,
|
|
2674
|
-
scrollableParents,
|
|
2675
|
-
innerWidth: window.innerWidth,
|
|
2676
|
-
innerHeight: window.innerHeight
|
|
2677
|
-
});
|
|
2678
2671
|
let newPlacement = _placement;
|
|
2679
2672
|
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
2680
2673
|
newPlacement = newPlacement.replace('bottom', 'top');
|
|
@@ -2682,10 +2675,10 @@ const usePopupPosition = ({
|
|
|
2682
2675
|
if (availableSpace.top < 0 && availableSpace.bottom > 0) {
|
|
2683
2676
|
newPlacement = newPlacement.replace('top', 'bottom');
|
|
2684
2677
|
}
|
|
2685
|
-
if (availableSpace.left < 0 && availableSpace.right > 0) {
|
|
2678
|
+
if (availableSpace.left < 0 && (availableSpace.right > 0 || availableSpace.right < popupRect.width)) {
|
|
2686
2679
|
newPlacement = newPlacement.replace('Right', 'Left');
|
|
2687
2680
|
}
|
|
2688
|
-
if (availableSpace.right < 0 && availableSpace.left > 0) {
|
|
2681
|
+
if (availableSpace.right < 0 && (availableSpace.left > 0 || availableSpace.left < popupRect.width)) {
|
|
2689
2682
|
newPlacement = newPlacement.replace('Left', 'Right');
|
|
2690
2683
|
}
|
|
2691
2684
|
if (availableSpace.right < 0 && availableSpace.left < 0) {
|
|
@@ -2765,6 +2758,7 @@ const usePopupPosition = ({
|
|
|
2765
2758
|
document.body.addEventListener("resize", calculatePosition, options);
|
|
2766
2759
|
return () => {
|
|
2767
2760
|
controller.abort();
|
|
2761
|
+
setPopupPosition({});
|
|
2768
2762
|
// setPositionRelative('unset');
|
|
2769
2763
|
};
|
|
2770
2764
|
}, [open, targetRef, popupContainer, inBody, calculatePosition]);
|