x-ui-design 0.9.11 → 0.9.13
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 +4 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -10
- package/dist/index.js.map +1 -1
- package/lib/hooks/usePopupPosition.ts +5 -12
- package/package.json +1 -1
- package/src/app/page.tsx +4 -4
|
@@ -68,7 +68,7 @@ export const usePopupPosition = ({
|
|
|
68
68
|
left: relativePosition.left + (targetRef.current?.offsetLeft || 0) - (targetRef.current?.clientWidth || 0) / 2
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
if (e?.target && inBody) {
|
|
71
|
+
if (e?.target === scrollableParents && inBody) {
|
|
72
72
|
setOpen(false);
|
|
73
73
|
setPopupPosition({});
|
|
74
74
|
|
|
@@ -85,16 +85,7 @@ export const usePopupPosition = ({
|
|
|
85
85
|
left: container.left - (popupRect.width + OFFSET),
|
|
86
86
|
right: (inBody ? window.innerWidth : (scrollableParents?.clientWidth || 0)) - (container.right + popupRect.width + OFFSET)
|
|
87
87
|
};
|
|
88
|
-
|
|
89
|
-
console.log({
|
|
90
|
-
popupRect,
|
|
91
|
-
container,
|
|
92
|
-
scrollableParents,
|
|
93
|
-
innerWidth: window.innerWidth,
|
|
94
|
-
innerHeight: window.innerHeight
|
|
95
|
-
});
|
|
96
88
|
|
|
97
|
-
|
|
98
89
|
let newPlacement = _placement;
|
|
99
90
|
|
|
100
91
|
if (availableSpace.bottom < 0 && availableSpace.top > 0) {
|
|
@@ -105,11 +96,11 @@ export const usePopupPosition = ({
|
|
|
105
96
|
newPlacement = newPlacement.replace('top', 'bottom') as Placement;
|
|
106
97
|
}
|
|
107
98
|
|
|
108
|
-
if (availableSpace.left < 0 && availableSpace.right > 0) {
|
|
99
|
+
if (availableSpace.left < 0 && (availableSpace.right > 0 || availableSpace.right < popupRect.width)) {
|
|
109
100
|
newPlacement = newPlacement.replace('Right', 'Left') as Placement;
|
|
110
101
|
}
|
|
111
102
|
|
|
112
|
-
if (availableSpace.right < 0 && availableSpace.left > 0) {
|
|
103
|
+
if (availableSpace.right < 0 && (availableSpace.left > 0 || availableSpace.left < popupRect.width)) {
|
|
113
104
|
newPlacement = newPlacement.replace('Left', 'Right') as Placement;
|
|
114
105
|
}
|
|
115
106
|
|
|
@@ -199,7 +190,9 @@ export const usePopupPosition = ({
|
|
|
199
190
|
return () => {
|
|
200
191
|
controller.abort();
|
|
201
192
|
|
|
193
|
+
setPopupPosition({});
|
|
202
194
|
// setPositionRelative('unset');
|
|
195
|
+
|
|
203
196
|
};
|
|
204
197
|
}, [open, targetRef, popupContainer, inBody, calculatePosition]);
|
|
205
198
|
|
package/package.json
CHANGED
package/src/app/page.tsx
CHANGED
|
@@ -143,15 +143,15 @@ export default function Home() {
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
<div className='dsfdf' style={{ display: 'flex', width: 1200, border: '1px solid', overflow: 'scroll', height: 700 }}>
|
|
146
|
-
<div style={{ minWidth:
|
|
147
|
-
<div style={{ height:
|
|
146
|
+
<div style={{ minWidth: 100 }} />
|
|
147
|
+
<div style={{ height: 700, border: '1px solid',
|
|
148
148
|
position: 'relative'
|
|
149
149
|
}}>
|
|
150
|
-
<div style={{ height:
|
|
150
|
+
<div style={{ height: 700,
|
|
151
151
|
position: 'relative'
|
|
152
152
|
}} />
|
|
153
153
|
<Popover
|
|
154
|
-
placement='
|
|
154
|
+
placement='bottomLeft'
|
|
155
155
|
content={
|
|
156
156
|
<Suspense>
|
|
157
157
|
<Result
|