@diwauhris/ui 1.7.28 → 1.7.30
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 +17 -2
- package/lib/index.mjs +18 -3
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1229,7 +1229,7 @@ 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.
|
|
1232
|
+
(0, react.useLayoutEffect)(() => {
|
|
1233
1233
|
if (!isOpen || !wrapperRef.current) return;
|
|
1234
1234
|
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1235
1235
|
setPanelStyle({
|
|
@@ -1242,6 +1242,19 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1242
1242
|
overscrollBehavior: "contain"
|
|
1243
1243
|
});
|
|
1244
1244
|
}, [isOpen]);
|
|
1245
|
+
(0, react.useEffect)(() => {
|
|
1246
|
+
if (!isOpen) return;
|
|
1247
|
+
const close = () => setIsOpen(false);
|
|
1248
|
+
window.addEventListener("scroll", close, {
|
|
1249
|
+
capture: true,
|
|
1250
|
+
passive: true
|
|
1251
|
+
});
|
|
1252
|
+
window.addEventListener("resize", close);
|
|
1253
|
+
return () => {
|
|
1254
|
+
window.removeEventListener("scroll", close, { capture: true });
|
|
1255
|
+
window.removeEventListener("resize", close);
|
|
1256
|
+
};
|
|
1257
|
+
}, [isOpen]);
|
|
1245
1258
|
(0, react.useEffect)(() => {
|
|
1246
1259
|
if (!isOpen) setHighlightIndex(-1);
|
|
1247
1260
|
}, [isOpen]);
|
|
@@ -4088,10 +4101,12 @@ function Menu({ trigger, items, ariaLabel = "Menu", align = "right", open: contr
|
|
|
4088
4101
|
right: Math.max(MARGIN, window.innerWidth - rect.right),
|
|
4089
4102
|
left: "auto"
|
|
4090
4103
|
};
|
|
4104
|
+
const maxHeight = flipUp ? Math.max(120, rect.top - GAP - MARGIN) : Math.max(120, spaceBelow - GAP - MARGIN);
|
|
4091
4105
|
setPanelStyle({
|
|
4092
4106
|
position: "fixed",
|
|
4093
4107
|
...flipUp ? { bottom: Math.max(MARGIN, window.innerHeight - rect.top + GAP) } : { top: rect.bottom + GAP },
|
|
4094
4108
|
...horizontal,
|
|
4109
|
+
maxHeight,
|
|
4095
4110
|
zIndex: 9999,
|
|
4096
4111
|
minWidth: PANEL_MIN_WIDTH,
|
|
4097
4112
|
maxWidth: available
|
|
@@ -4202,7 +4217,7 @@ function Menu({ trigger, items, ariaLabel = "Menu", align = "right", open: contr
|
|
|
4202
4217
|
role: "menu",
|
|
4203
4218
|
"aria-label": ariaLabel,
|
|
4204
4219
|
style: panelStyle,
|
|
4205
|
-
className: cn("overflow-
|
|
4220
|
+
className: cn("overflow-y-auto overscroll-contain rounded-xl border border-slate-200 bg-white py-1 shadow-xl", panelClassName),
|
|
4206
4221
|
children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4207
4222
|
ref: (node) => {
|
|
4208
4223
|
itemRefs.current[index] = node;
|
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, useMemo, useRef, useState } from "react";
|
|
4
|
+
import React, { cloneElement, createContext, createElement, isValidElement, use, useCallback, useContext, useEffect, useId, useLayoutEffect, 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,7 +1205,7 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1205
1205
|
document.addEventListener("mousedown", handleClickOutside);
|
|
1206
1206
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1207
1207
|
}, []);
|
|
1208
|
-
|
|
1208
|
+
useLayoutEffect(() => {
|
|
1209
1209
|
if (!isOpen || !wrapperRef.current) return;
|
|
1210
1210
|
const rect = wrapperRef.current.getBoundingClientRect();
|
|
1211
1211
|
setPanelStyle({
|
|
@@ -1218,6 +1218,19 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1218
1218
|
overscrollBehavior: "contain"
|
|
1219
1219
|
});
|
|
1220
1220
|
}, [isOpen]);
|
|
1221
|
+
useEffect(() => {
|
|
1222
|
+
if (!isOpen) return;
|
|
1223
|
+
const close = () => setIsOpen(false);
|
|
1224
|
+
window.addEventListener("scroll", close, {
|
|
1225
|
+
capture: true,
|
|
1226
|
+
passive: true
|
|
1227
|
+
});
|
|
1228
|
+
window.addEventListener("resize", close);
|
|
1229
|
+
return () => {
|
|
1230
|
+
window.removeEventListener("scroll", close, { capture: true });
|
|
1231
|
+
window.removeEventListener("resize", close);
|
|
1232
|
+
};
|
|
1233
|
+
}, [isOpen]);
|
|
1221
1234
|
useEffect(() => {
|
|
1222
1235
|
if (!isOpen) setHighlightIndex(-1);
|
|
1223
1236
|
}, [isOpen]);
|
|
@@ -4064,10 +4077,12 @@ function Menu({ trigger, items, ariaLabel = "Menu", align = "right", open: contr
|
|
|
4064
4077
|
right: Math.max(MARGIN, window.innerWidth - rect.right),
|
|
4065
4078
|
left: "auto"
|
|
4066
4079
|
};
|
|
4080
|
+
const maxHeight = flipUp ? Math.max(120, rect.top - GAP - MARGIN) : Math.max(120, spaceBelow - GAP - MARGIN);
|
|
4067
4081
|
setPanelStyle({
|
|
4068
4082
|
position: "fixed",
|
|
4069
4083
|
...flipUp ? { bottom: Math.max(MARGIN, window.innerHeight - rect.top + GAP) } : { top: rect.bottom + GAP },
|
|
4070
4084
|
...horizontal,
|
|
4085
|
+
maxHeight,
|
|
4071
4086
|
zIndex: 9999,
|
|
4072
4087
|
minWidth: PANEL_MIN_WIDTH,
|
|
4073
4088
|
maxWidth: available
|
|
@@ -4178,7 +4193,7 @@ function Menu({ trigger, items, ariaLabel = "Menu", align = "right", open: contr
|
|
|
4178
4193
|
role: "menu",
|
|
4179
4194
|
"aria-label": ariaLabel,
|
|
4180
4195
|
style: panelStyle,
|
|
4181
|
-
className: cn("overflow-
|
|
4196
|
+
className: cn("overflow-y-auto overscroll-contain rounded-xl border border-slate-200 bg-white py-1 shadow-xl", panelClassName),
|
|
4182
4197
|
children: items.map((item, index) => /* @__PURE__ */ jsxs("button", {
|
|
4183
4198
|
ref: (node) => {
|
|
4184
4199
|
itemRefs.current[index] = node;
|