x-ui-design 0.7.52 → 0.7.54
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 +21 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +21 -58
- package/dist/index.js.map +1 -1
- package/lib/components/DatePicker/TimePicker/TimePicker.tsx +31 -65
- package/package.json +1 -1
- package/src/app/page.tsx +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -2828,72 +2828,35 @@ 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
|
-
if (!inputRef.current) {
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
const
|
|
2848
|
-
const
|
|
2849
|
-
const
|
|
2850
|
-
const
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
shouldShowAbove
|
|
2854
|
-
});
|
|
2855
|
-
if (open && !shouldShowBelow && !shouldShowAbove) {
|
|
2856
|
-
setDropdownPosition(previousDropdownPosition => {
|
|
2857
|
-
if (!Object.keys(previousDropdownPosition).length) {
|
|
2858
|
-
if (getPopupContainer) {
|
|
2859
|
-
return {
|
|
2860
|
-
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop - 230,
|
|
2861
|
-
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2862
|
-
};
|
|
2863
|
-
} else {
|
|
2864
|
-
return {
|
|
2865
|
-
top: (inputRef.current?.offsetTop || 0) + (inputRef.current?.offsetHeight || 0),
|
|
2866
|
-
left: inputRef.current?.offsetLeft
|
|
2867
|
-
};
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
return previousDropdownPosition;
|
|
2871
|
-
});
|
|
2872
|
-
}
|
|
2832
|
+
if (!inputRef.current) return {};
|
|
2833
|
+
const inputRect = inputRef.current.getBoundingClientRect();
|
|
2834
|
+
const popupEl = popupRef.current;
|
|
2835
|
+
const dropdownHeight = popupEl?.offsetHeight || 230;
|
|
2836
|
+
const popupContainer = getPopupContainer ? getPopupContainer(document.body) : getScrollParents(inputRef.current)[1] || document.body;
|
|
2837
|
+
const containerRect = popupContainer.getBoundingClientRect();
|
|
2838
|
+
const spaceAbove = inputRect.top - containerRect.top;
|
|
2839
|
+
const spaceBelow = containerRect.bottom - inputRect.bottom;
|
|
2840
|
+
const shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
2873
2841
|
if (getPopupContainer) {
|
|
2874
|
-
if (
|
|
2875
|
-
toBelow();
|
|
2876
|
-
return;
|
|
2877
|
-
}
|
|
2878
|
-
if (!shouldShowAbove) {
|
|
2879
|
-
toAbove();
|
|
2880
|
-
}
|
|
2881
|
-
} else {
|
|
2882
|
-
if (shouldShowBelow) {
|
|
2842
|
+
if (shouldShowAbove) {
|
|
2883
2843
|
setDropdownPosition({
|
|
2884
|
-
top: inputRef.current.
|
|
2885
|
-
left: inputRef.current?.
|
|
2844
|
+
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop - 230,
|
|
2845
|
+
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2886
2846
|
});
|
|
2887
|
-
|
|
2888
|
-
}
|
|
2889
|
-
if (shouldShowAbove) {
|
|
2847
|
+
} else {
|
|
2890
2848
|
setDropdownPosition({
|
|
2891
|
-
top: inputRef.current?.
|
|
2892
|
-
left: inputRef.current?.
|
|
2849
|
+
top: (inputRef.current?.getBoundingClientRect().top || 0) + document.documentElement.scrollTop + (inputRef.current?.offsetHeight || 0),
|
|
2850
|
+
left: (inputRef.current?.getBoundingClientRect().left || 0) + document.documentElement.scrollLeft
|
|
2893
2851
|
});
|
|
2894
2852
|
}
|
|
2853
|
+
} else {
|
|
2854
|
+
setDropdownPosition({
|
|
2855
|
+
top: shouldShowAbove ? inputRef.current.offsetTop - (popupEl?.offsetHeight || dropdownHeight) - 8 : inputRef.current.offsetTop + inputRef.current.offsetHeight,
|
|
2856
|
+
left: inputRef.current.offsetLeft
|
|
2857
|
+
});
|
|
2895
2858
|
}
|
|
2896
|
-
}, [open,
|
|
2859
|
+
}, [open, getPopupContainer]);
|
|
2897
2860
|
const getScrollParents = useCallback(element => {
|
|
2898
2861
|
const parents = [];
|
|
2899
2862
|
let current = element.parentElement;
|