x-ui-design 0.8.21 → 0.8.23
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.
|
@@ -27,9 +27,8 @@ const Popover = ({
|
|
|
27
27
|
|
|
28
28
|
const [innerOpen, setInnerOpen] = useState(false);
|
|
29
29
|
|
|
30
|
-
const [hover, setHover] = useState(false);
|
|
31
30
|
const isOpen = visible !== undefined ? visible : open !== undefined ? open : innerOpen;
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
const { dropdownPosition, showPlacement } = usePosition({
|
|
34
33
|
isOpen,
|
|
35
34
|
offset: 10,
|
|
@@ -39,6 +38,13 @@ const Popover = ({
|
|
|
39
38
|
getPopupContainer: getPopupContainer?.(triggerRef.current as HTMLElement)
|
|
40
39
|
});
|
|
41
40
|
|
|
41
|
+
console.log({
|
|
42
|
+
isOpen,
|
|
43
|
+
popupRef,
|
|
44
|
+
placement,
|
|
45
|
+
triggerRef
|
|
46
|
+
});
|
|
47
|
+
|
|
42
48
|
useEffect(() => {
|
|
43
49
|
const handleClickOutside = (e: MouseEvent) => {
|
|
44
50
|
if (
|
|
@@ -67,8 +73,6 @@ const Popover = ({
|
|
|
67
73
|
}, [isOpen, trigger]);
|
|
68
74
|
|
|
69
75
|
const handleOnMouseEnter = useCallback(() => {
|
|
70
|
-
setHover(true);
|
|
71
|
-
|
|
72
76
|
if (trigger === "hover") {
|
|
73
77
|
onVisibleChange?.(true);
|
|
74
78
|
setInnerOpen(true);
|
|
@@ -76,8 +80,6 @@ const Popover = ({
|
|
|
76
80
|
}, [trigger]);
|
|
77
81
|
|
|
78
82
|
const handleOnMouseLeave = useCallback(() => {
|
|
79
|
-
setHover(false);
|
|
80
|
-
|
|
81
83
|
if (trigger === "hover") {
|
|
82
84
|
onVisibleChange?.(false);
|
|
83
85
|
setInnerOpen(false);
|
|
@@ -121,7 +123,7 @@ const Popover = ({
|
|
|
121
123
|
{...childProps}
|
|
122
124
|
className={clsx(prefixCls, `${prefixCls}-${placement}`, overlayClassName)}
|
|
123
125
|
style={{
|
|
124
|
-
zIndex:
|
|
126
|
+
zIndex: 1000,
|
|
125
127
|
position: "absolute",
|
|
126
128
|
...overlayStyle,
|
|
127
129
|
...dropdownPosition
|
package/lib/hooks/usePosition.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
RefObject,
|
|
5
5
|
useCallback,
|
|
6
6
|
useEffect,
|
|
7
|
-
useMemo,
|
|
8
7
|
useState
|
|
9
8
|
} from "react";
|
|
10
9
|
|
|
@@ -81,8 +80,6 @@ export const usePosition = ({
|
|
|
81
80
|
return {};
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
debugger
|
|
85
|
-
|
|
86
83
|
const inputRect = triggerRef.current?.getBoundingClientRect();
|
|
87
84
|
const dropdownHeight = popupRef.current?.offsetHeight || (popupRef.current?.offsetHeight || 0);
|
|
88
85
|
const containerRect = (getPopupContainer || getScrollParent(triggerRef.current, true) || document.body).getBoundingClientRect();
|
|
@@ -102,7 +99,7 @@ export const usePosition = ({
|
|
|
102
99
|
containerRect
|
|
103
100
|
);
|
|
104
101
|
|
|
105
|
-
const _center = (minLeft + maxLeft) < (popupRef.current?.offsetWidth || 0) ? 'center' : ''
|
|
102
|
+
const _center = (minLeft + maxLeft) < (popupRef.current?.offsetWidth || 0) ? 'center' : ''
|
|
106
103
|
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
107
104
|
|
|
108
105
|
const _top = (inputRect.top || 0) + document.documentElement.scrollTop;
|
|
@@ -199,11 +196,11 @@ export const usePosition = ({
|
|
|
199
196
|
dropdownPosition
|
|
200
197
|
]);
|
|
201
198
|
|
|
202
|
-
return
|
|
199
|
+
return {
|
|
203
200
|
showPlacement,
|
|
204
201
|
dropdownPosition: {
|
|
205
202
|
..._dropdownPosition,
|
|
206
203
|
opacity: Object.keys(_dropdownPosition).length ? 1 : 0
|
|
207
204
|
}
|
|
208
|
-
}
|
|
205
|
+
}
|
|
209
206
|
}
|