x-ui-design 0.7.53 → 0.7.55
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 +10 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -29
- package/dist/index.js.map +1 -1
- package/lib/components/DatePicker/TimePicker/TimePicker.tsx +39 -62
- package/package.json +1 -1
- package/src/app/page.tsx +15 -11
package/dist/index.esm.js
CHANGED
|
@@ -2828,49 +2828,30 @@ const TimePicker = ({
|
|
|
2828
2828
|
}
|
|
2829
2829
|
}
|
|
2830
2830
|
};
|
|
2831
|
-
const toAbove = () => {
|
|
2832
|
-
setDropdownPosition({
|
|
2833
|
-
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop + (inputRef.current?.offsetHeight || 0),
|
|
2834
|
-
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2835
|
-
});
|
|
2836
|
-
};
|
|
2837
|
-
const toBelow = () => {
|
|
2838
|
-
setDropdownPosition({
|
|
2839
|
-
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop - 230,
|
|
2840
|
-
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2841
|
-
});
|
|
2842
|
-
};
|
|
2843
2831
|
const dropdownPossition = useCallback(() => {
|
|
2844
2832
|
if (!inputRef.current) return {};
|
|
2845
2833
|
const inputRect = inputRef.current.getBoundingClientRect();
|
|
2846
2834
|
const popupEl = popupRef.current;
|
|
2847
2835
|
const dropdownHeight = popupEl?.offsetHeight || 230;
|
|
2848
|
-
|
|
2849
|
-
const popupContainer = getPopupContainer ? getPopupContainer(document.body) :
|
|
2836
|
+
const parents = getScrollParents(inputRef.current);
|
|
2837
|
+
const popupContainer = getPopupContainer ? getPopupContainer(document.body) : parents[parents.length - 2] || parents[1] || document.body;
|
|
2850
2838
|
const containerRect = popupContainer.getBoundingClientRect();
|
|
2851
|
-
// 2️⃣ Compute visible space inside the container
|
|
2852
2839
|
const spaceAbove = inputRect.top - containerRect.top;
|
|
2853
2840
|
const spaceBelow = containerRect.bottom - inputRect.bottom;
|
|
2854
2841
|
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
|
|
2865
2842
|
if (getPopupContainer) {
|
|
2866
|
-
// Position relative to container (like Antd with custom popup container)
|
|
2867
2843
|
if (shouldShowAbove) {
|
|
2868
|
-
|
|
2844
|
+
setDropdownPosition({
|
|
2845
|
+
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop - 230,
|
|
2846
|
+
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2847
|
+
});
|
|
2869
2848
|
} else {
|
|
2870
|
-
|
|
2849
|
+
setDropdownPosition({
|
|
2850
|
+
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop + (inputRef.current?.offsetHeight || 0),
|
|
2851
|
+
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2852
|
+
});
|
|
2871
2853
|
}
|
|
2872
2854
|
} else {
|
|
2873
|
-
// Position relative to nearest scrollable container (Antd default)
|
|
2874
2855
|
setDropdownPosition({
|
|
2875
2856
|
top: shouldShowAbove ? inputRef.current.offsetTop - (popupEl?.offsetHeight || dropdownHeight) - 8 : inputRef.current.offsetTop + inputRef.current.offsetHeight,
|
|
2876
2857
|
left: inputRef.current.offsetLeft
|