@diwauhris/ui 1.7.31 → 1.7.33
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 +22 -19
- package/lib/index.mjs +23 -20
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1229,34 +1229,37 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1229
1229
|
document.addEventListener("mousedown", handleClickOutside);
|
|
1230
1230
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1231
1231
|
}, []);
|
|
1232
|
-
(0, react.useLayoutEffect)(() => {
|
|
1233
|
-
if (!isOpen || !wrapperRef.current) return;
|
|
1234
|
-
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1235
|
-
setPanelStyle({
|
|
1236
|
-
position: "fixed",
|
|
1237
|
-
top: rect.bottom + 4,
|
|
1238
|
-
left: rect.left,
|
|
1239
|
-
zIndex: 9999,
|
|
1240
|
-
width: rect.width,
|
|
1241
|
-
pointerEvents: "auto",
|
|
1242
|
-
overscrollBehavior: "contain"
|
|
1243
|
-
});
|
|
1244
|
-
}, [isOpen]);
|
|
1245
1232
|
(0, react.useEffect)(() => {
|
|
1246
1233
|
if (!isOpen) return;
|
|
1247
|
-
const
|
|
1234
|
+
const updatePosition = () => {
|
|
1235
|
+
if (!wrapperRef.current) return;
|
|
1236
|
+
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1237
|
+
const dropUp = window.innerHeight - rect.bottom < 240 && rect.top > 240;
|
|
1238
|
+
setPanelStyle({
|
|
1239
|
+
position: "fixed",
|
|
1240
|
+
top: dropUp ? void 0 : rect.bottom + 4,
|
|
1241
|
+
bottom: dropUp ? window.innerHeight - rect.top + 4 : void 0,
|
|
1242
|
+
left: rect.left,
|
|
1243
|
+
zIndex: 9999,
|
|
1244
|
+
width: rect.width,
|
|
1245
|
+
pointerEvents: "auto",
|
|
1246
|
+
overscrollBehavior: "contain"
|
|
1247
|
+
});
|
|
1248
|
+
};
|
|
1249
|
+
const closeOnScroll = (e) => {
|
|
1248
1250
|
if (listRef.current && listRef.current.contains(e.target)) return;
|
|
1249
1251
|
setIsOpen(false);
|
|
1250
1252
|
};
|
|
1251
|
-
const
|
|
1252
|
-
window.addEventListener("scroll",
|
|
1253
|
+
const raf = requestAnimationFrame(updatePosition);
|
|
1254
|
+
window.addEventListener("scroll", closeOnScroll, {
|
|
1253
1255
|
capture: true,
|
|
1254
1256
|
passive: true
|
|
1255
1257
|
});
|
|
1256
|
-
window.addEventListener("resize",
|
|
1258
|
+
window.addEventListener("resize", updatePosition);
|
|
1257
1259
|
return () => {
|
|
1258
|
-
|
|
1259
|
-
window.removeEventListener("
|
|
1260
|
+
cancelAnimationFrame(raf);
|
|
1261
|
+
window.removeEventListener("scroll", closeOnScroll, { capture: true });
|
|
1262
|
+
window.removeEventListener("resize", updatePosition);
|
|
1260
1263
|
};
|
|
1261
1264
|
}, [isOpen]);
|
|
1262
1265
|
(0, react.useEffect)(() => {
|
package/lib/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import React, { cloneElement, createContext, createElement, isValidElement, use, useCallback, useContext, useEffect, useId,
|
|
4
|
+
import React, { cloneElement, createContext, createElement, isValidElement, use, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
import { AlertCircle, AlertTriangle, Archive, ArchiveRestore, ArrowDown, Ban, CalendarDays, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, Clock, Command, File, Home, Info, Minus, RotateCcw, Search as Search$1, ShieldCheck, TrendingDown, TrendingUp, UploadCloud, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
@@ -1205,34 +1205,37 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1205
1205
|
document.addEventListener("mousedown", handleClickOutside);
|
|
1206
1206
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1207
1207
|
}, []);
|
|
1208
|
-
useLayoutEffect(() => {
|
|
1209
|
-
if (!isOpen || !wrapperRef.current) return;
|
|
1210
|
-
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1211
|
-
setPanelStyle({
|
|
1212
|
-
position: "fixed",
|
|
1213
|
-
top: rect.bottom + 4,
|
|
1214
|
-
left: rect.left,
|
|
1215
|
-
zIndex: 9999,
|
|
1216
|
-
width: rect.width,
|
|
1217
|
-
pointerEvents: "auto",
|
|
1218
|
-
overscrollBehavior: "contain"
|
|
1219
|
-
});
|
|
1220
|
-
}, [isOpen]);
|
|
1221
1208
|
useEffect(() => {
|
|
1222
1209
|
if (!isOpen) return;
|
|
1223
|
-
const
|
|
1210
|
+
const updatePosition = () => {
|
|
1211
|
+
if (!wrapperRef.current) return;
|
|
1212
|
+
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1213
|
+
const dropUp = window.innerHeight - rect.bottom < 240 && rect.top > 240;
|
|
1214
|
+
setPanelStyle({
|
|
1215
|
+
position: "fixed",
|
|
1216
|
+
top: dropUp ? void 0 : rect.bottom + 4,
|
|
1217
|
+
bottom: dropUp ? window.innerHeight - rect.top + 4 : void 0,
|
|
1218
|
+
left: rect.left,
|
|
1219
|
+
zIndex: 9999,
|
|
1220
|
+
width: rect.width,
|
|
1221
|
+
pointerEvents: "auto",
|
|
1222
|
+
overscrollBehavior: "contain"
|
|
1223
|
+
});
|
|
1224
|
+
};
|
|
1225
|
+
const closeOnScroll = (e) => {
|
|
1224
1226
|
if (listRef.current && listRef.current.contains(e.target)) return;
|
|
1225
1227
|
setIsOpen(false);
|
|
1226
1228
|
};
|
|
1227
|
-
const
|
|
1228
|
-
window.addEventListener("scroll",
|
|
1229
|
+
const raf = requestAnimationFrame(updatePosition);
|
|
1230
|
+
window.addEventListener("scroll", closeOnScroll, {
|
|
1229
1231
|
capture: true,
|
|
1230
1232
|
passive: true
|
|
1231
1233
|
});
|
|
1232
|
-
window.addEventListener("resize",
|
|
1234
|
+
window.addEventListener("resize", updatePosition);
|
|
1233
1235
|
return () => {
|
|
1234
|
-
|
|
1235
|
-
window.removeEventListener("
|
|
1236
|
+
cancelAnimationFrame(raf);
|
|
1237
|
+
window.removeEventListener("scroll", closeOnScroll, { capture: true });
|
|
1238
|
+
window.removeEventListener("resize", updatePosition);
|
|
1236
1239
|
};
|
|
1237
1240
|
}, [isOpen]);
|
|
1238
1241
|
useEffect(() => {
|