x-ui-design 0.7.51 → 0.7.53
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 +31 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +31 -44
- package/dist/index.js.map +1 -1
- package/lib/components/DatePicker/TimePicker/TimePicker.tsx +49 -55
- package/package.json +1 -1
- package/src/app/page.tsx +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -2841,55 +2841,42 @@ const TimePicker = ({
|
|
|
2841
2841
|
});
|
|
2842
2842
|
};
|
|
2843
2843
|
const dropdownPossition = useCallback(() => {
|
|
2844
|
-
if (!inputRef.current) {
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
const
|
|
2848
|
-
|
|
2849
|
-
const
|
|
2850
|
-
const
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
}
|
|
2866
|
-
return previousDropdownPosition;
|
|
2867
|
-
});
|
|
2868
|
-
}
|
|
2844
|
+
if (!inputRef.current) return {};
|
|
2845
|
+
const inputRect = inputRef.current.getBoundingClientRect();
|
|
2846
|
+
const popupEl = popupRef.current;
|
|
2847
|
+
const dropdownHeight = popupEl?.offsetHeight || 230;
|
|
2848
|
+
// 1️⃣ Determine the container for popup
|
|
2849
|
+
const popupContainer = getPopupContainer ? getPopupContainer(document.body) : getScrollParents(inputRef.current)[1] || document.body;
|
|
2850
|
+
const containerRect = popupContainer.getBoundingClientRect();
|
|
2851
|
+
// 2️⃣ Compute visible space inside the container
|
|
2852
|
+
const spaceAbove = inputRect.top - containerRect.top;
|
|
2853
|
+
const spaceBelow = containerRect.bottom - inputRect.bottom;
|
|
2854
|
+
const shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
2855
|
+
const shouldShowBelow = !shouldShowAbove;
|
|
2856
|
+
// Debug
|
|
2857
|
+
console.log({
|
|
2858
|
+
container: popupContainer,
|
|
2859
|
+
spaceAbove,
|
|
2860
|
+
spaceBelow,
|
|
2861
|
+
shouldShowAbove,
|
|
2862
|
+
shouldShowBelow
|
|
2863
|
+
});
|
|
2864
|
+
// 3️⃣ Compute the position
|
|
2869
2865
|
if (getPopupContainer) {
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
return;
|
|
2873
|
-
}
|
|
2874
|
-
if (!shouldShowAbove) {
|
|
2866
|
+
// Position relative to container (like Antd with custom popup container)
|
|
2867
|
+
if (shouldShowAbove) {
|
|
2875
2868
|
toAbove();
|
|
2869
|
+
} else {
|
|
2870
|
+
toBelow();
|
|
2876
2871
|
}
|
|
2877
2872
|
} else {
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
return;
|
|
2884
|
-
}
|
|
2885
|
-
if (shouldShowAbove) {
|
|
2886
|
-
setDropdownPosition({
|
|
2887
|
-
top: inputRef.current?.offsetHeight - inputRef.current.offsetHeight - (popupRef.current?.offsetHeight || 0) - 8,
|
|
2888
|
-
left: inputRef.current?.offsetLeft
|
|
2889
|
-
});
|
|
2890
|
-
}
|
|
2873
|
+
// Position relative to nearest scrollable container (Antd default)
|
|
2874
|
+
setDropdownPosition({
|
|
2875
|
+
top: shouldShowAbove ? inputRef.current.offsetTop - (popupEl?.offsetHeight || dropdownHeight) - 8 : inputRef.current.offsetTop + inputRef.current.offsetHeight,
|
|
2876
|
+
left: inputRef.current.offsetLeft
|
|
2877
|
+
});
|
|
2891
2878
|
}
|
|
2892
|
-
}, [open,
|
|
2879
|
+
}, [open, getPopupContainer]);
|
|
2893
2880
|
const getScrollParents = useCallback(element => {
|
|
2894
2881
|
const parents = [];
|
|
2895
2882
|
let current = element.parentElement;
|