@diwauhris/ui 1.7.35 → 1.7.36
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/lib/index.cjs +32 -32
- package/lib/index.mjs +32 -32
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1233,40 +1233,40 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1233
1233
|
(0, react.useEffect)(() => {
|
|
1234
1234
|
isOpenRef.current = isOpen;
|
|
1235
1235
|
});
|
|
1236
|
-
const doUpdatePosition = (0, react.useCallback)(() => {
|
|
1237
|
-
if (!wrapperRef.current) return;
|
|
1238
|
-
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1239
|
-
const dropUp = window.innerHeight - rect.bottom < 240 && rect.top > 240;
|
|
1240
|
-
setPanelStyle({
|
|
1241
|
-
position: "fixed",
|
|
1242
|
-
top: dropUp ? void 0 : rect.bottom + 4,
|
|
1243
|
-
bottom: dropUp ? window.innerHeight - rect.top + 4 : void 0,
|
|
1244
|
-
left: rect.left,
|
|
1245
|
-
zIndex: 9999,
|
|
1246
|
-
width: rect.width,
|
|
1247
|
-
pointerEvents: "auto",
|
|
1248
|
-
overscrollBehavior: "contain"
|
|
1249
|
-
});
|
|
1250
|
-
}, []);
|
|
1251
|
-
(0, react.useEffect)(() => {
|
|
1252
|
-
if (!isOpen) return;
|
|
1253
|
-
const raf = requestAnimationFrame(doUpdatePosition);
|
|
1254
|
-
return () => cancelAnimationFrame(raf);
|
|
1255
|
-
}, [isOpen, doUpdatePosition]);
|
|
1256
1236
|
(0, react.useEffect)(() => {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1237
|
+
let prevTop;
|
|
1238
|
+
let prevBottom;
|
|
1239
|
+
let prevLeft = 0;
|
|
1240
|
+
let prevWidth = 0;
|
|
1241
|
+
let rafId;
|
|
1242
|
+
const loop = () => {
|
|
1243
|
+
if (isOpenRef.current && wrapperRef.current) {
|
|
1244
|
+
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1245
|
+
const dropUp = window.innerHeight - rect.bottom < 240 && rect.top > 240;
|
|
1246
|
+
const nextTop = dropUp ? void 0 : rect.bottom + 4;
|
|
1247
|
+
const nextBottom = dropUp ? window.innerHeight - rect.top + 4 : void 0;
|
|
1248
|
+
if (nextTop !== prevTop || nextBottom !== prevBottom || rect.left !== prevLeft || rect.width !== prevWidth) {
|
|
1249
|
+
prevTop = nextTop;
|
|
1250
|
+
prevBottom = nextBottom;
|
|
1251
|
+
prevLeft = rect.left;
|
|
1252
|
+
prevWidth = rect.width;
|
|
1253
|
+
setPanelStyle({
|
|
1254
|
+
position: "fixed",
|
|
1255
|
+
top: nextTop,
|
|
1256
|
+
bottom: nextBottom,
|
|
1257
|
+
left: rect.left,
|
|
1258
|
+
zIndex: 9999,
|
|
1259
|
+
width: rect.width,
|
|
1260
|
+
pointerEvents: "auto",
|
|
1261
|
+
overscrollBehavior: "contain"
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
rafId = requestAnimationFrame(loop);
|
|
1268
1266
|
};
|
|
1269
|
-
|
|
1267
|
+
rafId = requestAnimationFrame(loop);
|
|
1268
|
+
return () => cancelAnimationFrame(rafId);
|
|
1269
|
+
}, []);
|
|
1270
1270
|
(0, react.useEffect)(() => {
|
|
1271
1271
|
if (!isOpen) setHighlightIndex(-1);
|
|
1272
1272
|
}, [isOpen]);
|
package/lib/index.mjs
CHANGED
|
@@ -1209,40 +1209,40 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1209
1209
|
useEffect(() => {
|
|
1210
1210
|
isOpenRef.current = isOpen;
|
|
1211
1211
|
});
|
|
1212
|
-
const doUpdatePosition = useCallback(() => {
|
|
1213
|
-
if (!wrapperRef.current) return;
|
|
1214
|
-
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1215
|
-
const dropUp = window.innerHeight - rect.bottom < 240 && rect.top > 240;
|
|
1216
|
-
setPanelStyle({
|
|
1217
|
-
position: "fixed",
|
|
1218
|
-
top: dropUp ? void 0 : rect.bottom + 4,
|
|
1219
|
-
bottom: dropUp ? window.innerHeight - rect.top + 4 : void 0,
|
|
1220
|
-
left: rect.left,
|
|
1221
|
-
zIndex: 9999,
|
|
1222
|
-
width: rect.width,
|
|
1223
|
-
pointerEvents: "auto",
|
|
1224
|
-
overscrollBehavior: "contain"
|
|
1225
|
-
});
|
|
1226
|
-
}, []);
|
|
1227
|
-
useEffect(() => {
|
|
1228
|
-
if (!isOpen) return;
|
|
1229
|
-
const raf = requestAnimationFrame(doUpdatePosition);
|
|
1230
|
-
return () => cancelAnimationFrame(raf);
|
|
1231
|
-
}, [isOpen, doUpdatePosition]);
|
|
1232
1212
|
useEffect(() => {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1213
|
+
let prevTop;
|
|
1214
|
+
let prevBottom;
|
|
1215
|
+
let prevLeft = 0;
|
|
1216
|
+
let prevWidth = 0;
|
|
1217
|
+
let rafId;
|
|
1218
|
+
const loop = () => {
|
|
1219
|
+
if (isOpenRef.current && wrapperRef.current) {
|
|
1220
|
+
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1221
|
+
const dropUp = window.innerHeight - rect.bottom < 240 && rect.top > 240;
|
|
1222
|
+
const nextTop = dropUp ? void 0 : rect.bottom + 4;
|
|
1223
|
+
const nextBottom = dropUp ? window.innerHeight - rect.top + 4 : void 0;
|
|
1224
|
+
if (nextTop !== prevTop || nextBottom !== prevBottom || rect.left !== prevLeft || rect.width !== prevWidth) {
|
|
1225
|
+
prevTop = nextTop;
|
|
1226
|
+
prevBottom = nextBottom;
|
|
1227
|
+
prevLeft = rect.left;
|
|
1228
|
+
prevWidth = rect.width;
|
|
1229
|
+
setPanelStyle({
|
|
1230
|
+
position: "fixed",
|
|
1231
|
+
top: nextTop,
|
|
1232
|
+
bottom: nextBottom,
|
|
1233
|
+
left: rect.left,
|
|
1234
|
+
zIndex: 9999,
|
|
1235
|
+
width: rect.width,
|
|
1236
|
+
pointerEvents: "auto",
|
|
1237
|
+
overscrollBehavior: "contain"
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
rafId = requestAnimationFrame(loop);
|
|
1244
1242
|
};
|
|
1245
|
-
|
|
1243
|
+
rafId = requestAnimationFrame(loop);
|
|
1244
|
+
return () => cancelAnimationFrame(rafId);
|
|
1245
|
+
}, []);
|
|
1246
1246
|
useEffect(() => {
|
|
1247
1247
|
if (!isOpen) setHighlightIndex(-1);
|
|
1248
1248
|
}, [isOpen]);
|