@xsolla/xui-multi-select 0.185.3 → 0.185.5
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/native/index.js +38 -21
- package/native/index.js.map +1 -1
- package/native/index.mjs +39 -23
- package/native/index.mjs.map +1 -1
- package/package.json +5 -5
- package/web/index.js +38 -21
- package/web/index.js.map +1 -1
- package/web/index.mjs +39 -23
- package/web/index.mjs.map +1 -1
package/native/index.js
CHANGED
|
@@ -1718,13 +1718,23 @@ var useMultiSelectControl = ({
|
|
|
1718
1718
|
const isPlaceholder = !selectedItems || selectedItems.length === 0;
|
|
1719
1719
|
(0, import_react7.useEffect)(() => {
|
|
1720
1720
|
if (!containerRef.current) return;
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1721
|
+
let rafId = null;
|
|
1722
|
+
const syncItemsWidth = () => {
|
|
1723
|
+
rafId = null;
|
|
1724
|
+
if (!containerRef.current) return;
|
|
1725
|
+
const width = containerRef.current.getBoundingClientRect().width;
|
|
1726
|
+
setItemsWidth((prev) => prev === width ? prev : width);
|
|
1727
|
+
};
|
|
1728
|
+
const scheduleWidthSync = () => {
|
|
1729
|
+
if (rafId != null) return;
|
|
1730
|
+
rafId = requestAnimationFrame(syncItemsWidth);
|
|
1731
|
+
};
|
|
1732
|
+
const resizeObserver = new ResizeObserver(scheduleWidthSync);
|
|
1726
1733
|
resizeObserver.observe(containerRef.current);
|
|
1727
|
-
return () =>
|
|
1734
|
+
return () => {
|
|
1735
|
+
if (rafId != null) cancelAnimationFrame(rafId);
|
|
1736
|
+
resizeObserver.disconnect();
|
|
1737
|
+
};
|
|
1728
1738
|
}, [containerRef]);
|
|
1729
1739
|
const widthsDependencies = (0, import_react7.useMemo)(
|
|
1730
1740
|
() => ({
|
|
@@ -2281,25 +2291,32 @@ var MultiSelect = (0, import_react10.forwardRef)(
|
|
|
2281
2291
|
overflow: "hidden",
|
|
2282
2292
|
textOverflow: "ellipsis"
|
|
2283
2293
|
};
|
|
2284
|
-
const updateMenuPosition = (0, import_react10.useCallback)(() => {
|
|
2285
|
-
if (!isWeb || !controlRef.current) return;
|
|
2286
|
-
const rect = controlRef.current.getBoundingClientRect();
|
|
2287
|
-
setMenuPosition({
|
|
2288
|
-
left: rect.left,
|
|
2289
|
-
top: rect.bottom + 4,
|
|
2290
|
-
width: rect.width
|
|
2291
|
-
});
|
|
2292
|
-
}, []);
|
|
2293
2294
|
(0, import_react10.useEffect)(() => {
|
|
2294
2295
|
if (!isWeb || !controlMenuOpen || isDisable || !dropdownMenu) return;
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2296
|
+
let rafId = null;
|
|
2297
|
+
const repositionMenu = () => {
|
|
2298
|
+
rafId = null;
|
|
2299
|
+
if (!controlRef.current) return;
|
|
2300
|
+
const rect = controlRef.current.getBoundingClientRect();
|
|
2301
|
+
setMenuPosition({
|
|
2302
|
+
left: rect.left,
|
|
2303
|
+
top: rect.bottom + 4,
|
|
2304
|
+
width: rect.width
|
|
2305
|
+
});
|
|
2306
|
+
};
|
|
2307
|
+
const scheduleUpdate = () => {
|
|
2308
|
+
if (rafId != null) return;
|
|
2309
|
+
rafId = requestAnimationFrame(repositionMenu);
|
|
2310
|
+
};
|
|
2311
|
+
scheduleUpdate();
|
|
2312
|
+
window.addEventListener("resize", scheduleUpdate);
|
|
2313
|
+
window.addEventListener("scroll", scheduleUpdate, true);
|
|
2298
2314
|
return () => {
|
|
2299
|
-
|
|
2300
|
-
window.removeEventListener("
|
|
2315
|
+
if (rafId != null) cancelAnimationFrame(rafId);
|
|
2316
|
+
window.removeEventListener("resize", scheduleUpdate);
|
|
2317
|
+
window.removeEventListener("scroll", scheduleUpdate, true);
|
|
2301
2318
|
};
|
|
2302
|
-
}, [controlMenuOpen, dropdownMenu, isDisable
|
|
2319
|
+
}, [controlMenuOpen, dropdownMenu, isDisable]);
|
|
2303
2320
|
(0, import_react10.useEffect)(() => {
|
|
2304
2321
|
if (!isWeb || !dropdownMenu || !isOpen || isDisable) return;
|
|
2305
2322
|
const handleOutsideMouseDown = (event) => {
|