@diwauhris/ui 1.7.29 → 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 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.useEffect)(() => {
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]);
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
- useEffect(() => {
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]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@diwauhris/ui",
3
3
  "private": false,
4
- "version": "1.7.29",
4
+ "version": "1.7.30",
5
5
  "type": "module",
6
6
  "description": "DIWA UHRIS UI component library — React + Tailwind CSS",
7
7
  "keywords": [