@megha-ui/react 1.2.790 → 1.2.792

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.
@@ -18,6 +18,7 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
18
18
  const wrapperRef = useRef(null);
19
19
  const clearIconRef = useRef(null);
20
20
  const searchInputRef = useRef(null);
21
+ const searchOptionRef = useRef(null);
21
22
  const optionRefs = useRef([]);
22
23
  const [highlightIndex, setHighlightIndex] = useState(0);
23
24
  const [intermediateValues, setIntermediateValues] = useState(selectedValues);
@@ -28,6 +29,7 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
28
29
  const [collapsed, setCollapsed] = useState("");
29
30
  const [height, setHeight] = useState(0);
30
31
  const getOverflowParentHeight = (element, fallback) => {
32
+ var _a, _b;
31
33
  if (!element)
32
34
  return fallback;
33
35
  let parent = element.parentElement;
@@ -41,7 +43,9 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
41
43
  overflow === "scroll") {
42
44
  const parentRect = parent.getBoundingClientRect();
43
45
  const elementRect = element.getBoundingClientRect();
44
- return parentRect.height - elementRect.height;
46
+ const searchOptionRect = (_a = searchOptionRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
47
+ console.log(searchOptionRect);
48
+ return parentRect.height - elementRect.height - 4 - ((_b = searchOptionRect === null || searchOptionRect === void 0 ? void 0 : searchOptionRect.height) !== null && _b !== void 0 ? _b : 0);
45
49
  }
46
50
  console.log({ parent });
47
51
  parent = parent.parentElement;
@@ -320,10 +324,12 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
320
324
  };
321
325
  const handleClick = (e) => {
322
326
  const clearEle = document.getElementById(clearId || "");
323
- const rect = e.currentTarget.getBoundingClientRect();
324
- const viewportSpace = document.body.clientHeight - rect.bottom;
325
- const overflowSpace = getOverflowParentHeight(wrapperRef.current, viewportSpace);
326
- setHeight(overflowSpace);
327
+ setTimeout(() => {
328
+ const rect = e.currentTarget.getBoundingClientRect();
329
+ const viewportSpace = document.body.clientHeight - rect.bottom;
330
+ const overflowSpace = getOverflowParentHeight(wrapperRef.current, viewportSpace);
331
+ setHeight(overflowSpace);
332
+ }, 500);
327
333
  if (clearEle === e.target) {
328
334
  e.preventDefault();
329
335
  }
@@ -393,7 +399,7 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
393
399
  }, children: [isClear && (displayValue || selectedDisplay) && (_jsx("div", { style: { marginRight: "0.5rem" }, onClick: handleClear, id: clearId, title: "Click to clear the value", children: ClearIcon ? (ClearIcon) : (_jsx("span", { style: {
394
400
  color: "var(--form-border-color, #dbdfe9)",
395
401
  fontSize: "1rem",
396
- }, children: "X" })) })), disabled ? (Tooltip && Tooltip) : DropDownIcon ? (DropDownIcon) : (_jsx(HiChevronDown, { fontSize: "1rem" })), withTooltip && Tooltip && Tooltip] })] }), _jsxs("ul", { style: Object.assign(Object.assign({ width: isGrouping ? "max-content" : dropdownListWidth || "100%", position: "absolute", backgroundColor: dropdownListBG || "var(--dropdown-bg)", boxShadow: "0 4px 0.75rem rgba(0, 0, 0, 0.1)", border: "1px solid var(--divider, #f5f5f5)", zIndex: 10, marginTop: 4, borderRadius: 4, overflow: "hidden" }, clickStyle), { display: !isOpen ? "none" : "" }), children: [searchEnabled && (_jsx("li", { style: { padding: "0.5rem" }, children: _jsx("input", { ref: searchInputRef, type: "text", placeholder: "Search...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), disabled: disabled, style: {
402
+ }, children: "X" })) })), disabled ? (Tooltip && Tooltip) : DropDownIcon ? (DropDownIcon) : (_jsx(HiChevronDown, { fontSize: "1rem" })), withTooltip && Tooltip && Tooltip] })] }), _jsxs("ul", { style: Object.assign(Object.assign({ width: isGrouping ? "max-content" : dropdownListWidth || "100%", position: "absolute", backgroundColor: dropdownListBG || "var(--dropdown-bg)", boxShadow: "0 4px 0.75rem rgba(0, 0, 0, 0.1)", border: "1px solid var(--divider, #f5f5f5)", zIndex: 10, marginTop: 4, borderRadius: 4, overflow: "hidden" }, clickStyle), { display: !isOpen ? "none" : "" }), children: [searchEnabled && (_jsx("li", { style: { padding: "0.5rem" }, ref: searchOptionRef, children: _jsx("input", { ref: searchInputRef, type: "text", placeholder: "Search...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), disabled: disabled, style: {
397
403
  width: "100%",
398
404
  padding: "0.5rem",
399
405
  boxSizing: "border-box",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.790",
3
+ "version": "1.2.792",
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",