@diwauhris/ui 1.7.31 → 1.7.32

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 CHANGED
@@ -1229,34 +1229,33 @@ 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 close = (e) => {
1248
- if (listRef.current && listRef.current.contains(e.target)) return;
1249
- setIsOpen(false);
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
+ });
1250
1248
  };
1251
- const closeOnResize = () => setIsOpen(false);
1252
- window.addEventListener("scroll", close, {
1249
+ const raf = requestAnimationFrame(updatePosition);
1250
+ window.addEventListener("scroll", updatePosition, {
1253
1251
  capture: true,
1254
1252
  passive: true
1255
1253
  });
1256
- window.addEventListener("resize", closeOnResize);
1254
+ window.addEventListener("resize", updatePosition);
1257
1255
  return () => {
1258
- window.removeEventListener("scroll", close, { capture: true });
1259
- window.removeEventListener("resize", closeOnResize);
1256
+ cancelAnimationFrame(raf);
1257
+ window.removeEventListener("scroll", updatePosition, { capture: true });
1258
+ window.removeEventListener("resize", updatePosition);
1260
1259
  };
1261
1260
  }, [isOpen]);
1262
1261
  (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, useLayoutEffect, useMemo, useRef, useState } from "react";
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,33 @@ 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 close = (e) => {
1224
- if (listRef.current && listRef.current.contains(e.target)) return;
1225
- setIsOpen(false);
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
+ });
1226
1224
  };
1227
- const closeOnResize = () => setIsOpen(false);
1228
- window.addEventListener("scroll", close, {
1225
+ const raf = requestAnimationFrame(updatePosition);
1226
+ window.addEventListener("scroll", updatePosition, {
1229
1227
  capture: true,
1230
1228
  passive: true
1231
1229
  });
1232
- window.addEventListener("resize", closeOnResize);
1230
+ window.addEventListener("resize", updatePosition);
1233
1231
  return () => {
1234
- window.removeEventListener("scroll", close, { capture: true });
1235
- window.removeEventListener("resize", closeOnResize);
1232
+ cancelAnimationFrame(raf);
1233
+ window.removeEventListener("scroll", updatePosition, { capture: true });
1234
+ window.removeEventListener("resize", updatePosition);
1236
1235
  };
1237
1236
  }, [isOpen]);
1238
1237
  useEffect(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@diwauhris/ui",
3
3
  "private": false,
4
- "version": "1.7.31",
4
+ "version": "1.7.32",
5
5
  "type": "module",
6
6
  "description": "DIWA UHRIS UI component library — React + Tailwind CSS",
7
7
  "keywords": [