x-ui-design 0.8.96 → 0.9.11
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 +12 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/lib/hooks/usePopupPosition.ts +16 -7
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2653,6 +2653,11 @@ 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) {
|
|
2657
|
+
setOpen(false);
|
|
2658
|
+
setPopupPosition({});
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2656
2661
|
if (popupRef.current) {
|
|
2657
2662
|
const popupRect = popupRef.current.getBoundingClientRect();
|
|
2658
2663
|
const availableSpace = {
|
|
@@ -2661,6 +2666,13 @@ const usePopupPosition = ({
|
|
|
2661
2666
|
left: container.left - (popupRect.width + OFFSET),
|
|
2662
2667
|
right: (inBody ? window.innerWidth : scrollableParents?.clientWidth || 0) - (container.right + popupRect.width + OFFSET)
|
|
2663
2668
|
};
|
|
2669
|
+
console.log({
|
|
2670
|
+
popupRect,
|
|
2671
|
+
container,
|
|
2672
|
+
scrollableParents,
|
|
2673
|
+
innerWidth: window.innerWidth,
|
|
2674
|
+
innerHeight: window.innerHeight
|
|
2675
|
+
});
|
|
2664
2676
|
let newPlacement = _placement;
|
|
2665
2677
|
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
2666
2678
|
newPlacement = newPlacement.replace('bottom', 'top');
|
|
@@ -2684,11 +2696,6 @@ const usePopupPosition = ({
|
|
|
2684
2696
|
}
|
|
2685
2697
|
_setPlacement(newPlacement);
|
|
2686
2698
|
}
|
|
2687
|
-
if (e?.target === scrollableParents && inBody) {
|
|
2688
|
-
setOpen(false);
|
|
2689
|
-
setPopupPosition({});
|
|
2690
|
-
return;
|
|
2691
|
-
}
|
|
2692
2699
|
const _calculation = () => {
|
|
2693
2700
|
switch (_placement) {
|
|
2694
2701
|
case "bottom":
|