@diwauhris/ui 1.7.25 → 1.7.26

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
@@ -1417,6 +1417,7 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1417
1417
  const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(defaultOpen);
1418
1418
  const isOpen = isControlled ? open : uncontrolledOpen;
1419
1419
  const [popupStyle, setPopupStyle] = (0, react.useState)({});
1420
+ const [positioned, setPositioned] = (0, react.useState)(false);
1420
1421
  const wrapperRef = (0, react.useRef)(null);
1421
1422
  const popoverRef = (0, react.useRef)(null);
1422
1423
  const inputRef = (0, react.useRef)(null);
@@ -1456,6 +1457,7 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1456
1457
  if (!wrapperRef.current) return;
1457
1458
  const style = computePopupStyle(wrapperRef.current.getBoundingClientRect(), placement);
1458
1459
  setPopupStyle(style);
1460
+ setPositioned(false);
1459
1461
  setIsOpen(true);
1460
1462
  });
1461
1463
  }, 50);
@@ -1465,11 +1467,16 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1465
1467
  placement,
1466
1468
  setIsOpen
1467
1469
  ]);
1468
- (0, react.useEffect)(() => {
1469
- if (!isOpen || !popoverRef.current || !wrapperRef.current) return;
1470
+ (0, react.useLayoutEffect)(() => {
1471
+ if (!isOpen) {
1472
+ setPositioned(false);
1473
+ return;
1474
+ }
1475
+ if (!popoverRef.current || !wrapperRef.current) return;
1470
1476
  const measuredHeight = popoverRef.current.offsetHeight;
1471
1477
  const rect = wrapperRef.current.getBoundingClientRect();
1472
1478
  setPopupStyle(computePopupStyle(rect, placement, measuredHeight));
1479
+ setPositioned(true);
1473
1480
  }, [isOpen, placement]);
1474
1481
  (0, react.useEffect)(() => {
1475
1482
  function handleClickOutside(e) {
@@ -1569,7 +1576,10 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1569
1576
  }), isOpen && !disabled && !readOnly && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1570
1577
  ref: popoverRef,
1571
1578
  className: "pis-datepicker-popover",
1572
- style: popupStyle,
1579
+ style: {
1580
+ ...popupStyle,
1581
+ visibility: positioned ? void 0 : "hidden"
1582
+ },
1573
1583
  role: "dialog",
1574
1584
  "aria-label": ariaLabel ? `${ariaLabel} calendar` : "Date picker",
1575
1585
  "aria-modal": "false",
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";
@@ -1393,6 +1393,7 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1393
1393
  const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
1394
1394
  const isOpen = isControlled ? open : uncontrolledOpen;
1395
1395
  const [popupStyle, setPopupStyle] = useState({});
1396
+ const [positioned, setPositioned] = useState(false);
1396
1397
  const wrapperRef = useRef(null);
1397
1398
  const popoverRef = useRef(null);
1398
1399
  const inputRef = useRef(null);
@@ -1432,6 +1433,7 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1432
1433
  if (!wrapperRef.current) return;
1433
1434
  const style = computePopupStyle(wrapperRef.current.getBoundingClientRect(), placement);
1434
1435
  setPopupStyle(style);
1436
+ setPositioned(false);
1435
1437
  setIsOpen(true);
1436
1438
  });
1437
1439
  }, 50);
@@ -1441,11 +1443,16 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1441
1443
  placement,
1442
1444
  setIsOpen
1443
1445
  ]);
1444
- useEffect(() => {
1445
- if (!isOpen || !popoverRef.current || !wrapperRef.current) return;
1446
+ useLayoutEffect(() => {
1447
+ if (!isOpen) {
1448
+ setPositioned(false);
1449
+ return;
1450
+ }
1451
+ if (!popoverRef.current || !wrapperRef.current) return;
1446
1452
  const measuredHeight = popoverRef.current.offsetHeight;
1447
1453
  const rect = wrapperRef.current.getBoundingClientRect();
1448
1454
  setPopupStyle(computePopupStyle(rect, placement, measuredHeight));
1455
+ setPositioned(true);
1449
1456
  }, [isOpen, placement]);
1450
1457
  useEffect(() => {
1451
1458
  function handleClickOutside(e) {
@@ -1545,7 +1552,10 @@ function DatePicker({ value, onChange, placeholder, className, disabled, error,
1545
1552
  }), isOpen && !disabled && !readOnly && createPortal(/* @__PURE__ */ jsx("div", {
1546
1553
  ref: popoverRef,
1547
1554
  className: "pis-datepicker-popover",
1548
- style: popupStyle,
1555
+ style: {
1556
+ ...popupStyle,
1557
+ visibility: positioned ? void 0 : "hidden"
1558
+ },
1549
1559
  role: "dialog",
1550
1560
  "aria-label": ariaLabel ? `${ariaLabel} calendar` : "Date picker",
1551
1561
  "aria-modal": "false",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@diwauhris/ui",
3
3
  "private": false,
4
- "version": "1.7.25",
4
+ "version": "1.7.26",
5
5
  "type": "module",
6
6
  "description": "DIWA UHRIS UI component library — React + Tailwind CSS",
7
7
  "keywords": [