@megha-ui/react 1.2.784 → 1.2.786

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.
@@ -8,7 +8,7 @@ import Text from "../text";
8
8
  import Button from "../button";
9
9
  import { HiChevronDown } from "react-icons/hi";
10
10
  import { FaChevronDown, FaChevronUp } from "react-icons/fa";
11
- const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelAlignment = "vertical", labelFontSize, labelFontWeight, labelMarginBottom, labelClass, asteriskColor, label, disabled = false, width, searchEnabled = true, dropdownListWidth, marginBottom, marginTop, marginRight, marginLeft, required, dropdownListBG, searchBorderColor = "#2377ba", maxDropdownHeight = "12rem", border = "1px solid #dbdfe9", selectedCharLength = 0, menuFrom = "left", Tooltip, DropDownIcon, onMenuClose, onMenuOpen, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, compactDisplay = false, ultraCompactDisplay = false, isGrouping = false, isIcon = false, withValue = false, closeOnSelect = true, }) => {
11
+ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelAlignment = "vertical", labelFontSize, labelFontWeight, labelMarginBottom, labelClass, asteriskColor, label, disabled = false, width, searchEnabled = true, dropdownListWidth, marginBottom, marginTop, marginRight, marginLeft, required, dropdownListBG, searchBorderColor = "#2377ba", maxDropdownHeight, border = "1px solid #dbdfe9", selectedCharLength = 0, menuFrom = "left", Tooltip, DropDownIcon, onMenuClose, onMenuOpen, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, compactDisplay = false, ultraCompactDisplay = false, isGrouping = false, isIcon = false, withValue = false, closeOnSelect = true, }) => {
12
12
  var _a, _b;
13
13
  const { density } = useDensity();
14
14
  const [isOpen, setIsOpen] = useState(false);
@@ -27,6 +27,26 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
27
27
  });
28
28
  const [collapsed, setCollapsed] = useState("");
29
29
  const [height, setHeight] = useState(0);
30
+ const getOverflowParentHeight = (element, fallback) => {
31
+ if (!element)
32
+ return fallback;
33
+ let parent = element.parentElement;
34
+ while (parent) {
35
+ const style = window.getComputedStyle(parent);
36
+ const overflowY = style.overflowY;
37
+ const overflow = style.overflow;
38
+ if (overflowY === "auto" ||
39
+ overflowY === "scroll" ||
40
+ overflow === "auto" ||
41
+ overflow === "scroll") {
42
+ const parentRect = parent.getBoundingClientRect();
43
+ const elementRect = element.getBoundingClientRect();
44
+ return parentRect.bottom - elementRect.bottom;
45
+ }
46
+ parent = parent.parentElement;
47
+ }
48
+ return fallback;
49
+ };
30
50
  const calculateAutoPosition = () => {
31
51
  if (!wrapperRef.current)
32
52
  return;
@@ -298,9 +318,10 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
298
318
  };
299
319
  const handleClick = (e) => {
300
320
  const clearEle = document.getElementById(clearId || "");
301
- const screen = document.body.clientHeight;
302
321
  const rect = e.currentTarget.getBoundingClientRect();
303
- setHeight(screen - rect.bottom);
322
+ const viewportSpace = document.body.clientHeight - rect.bottom;
323
+ const overflowSpace = getOverflowParentHeight(wrapperRef.current, viewportSpace);
324
+ setHeight(overflowSpace);
304
325
  if (clearEle === e.target) {
305
326
  e.preventDefault();
306
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.784",
3
+ "version": "1.2.786",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",