@megha-ui/react 1.2.790 → 1.2.791
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,8 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
41
43
|
overflow === "scroll") {
|
|
42
44
|
const parentRect = parent.getBoundingClientRect();
|
|
43
45
|
const elementRect = element.getBoundingClientRect();
|
|
44
|
-
|
|
46
|
+
const searchOptionRect = (_a = searchOptionRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
47
|
+
return parentRect.height - elementRect.height - 4 - ((_b = searchOptionRect === null || searchOptionRect === void 0 ? void 0 : searchOptionRect.height) !== null && _b !== void 0 ? _b : 0);
|
|
45
48
|
}
|
|
46
49
|
console.log({ parent });
|
|
47
50
|
parent = parent.parentElement;
|
|
@@ -393,7 +396,7 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
393
396
|
}, 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
397
|
color: "var(--form-border-color, #dbdfe9)",
|
|
395
398
|
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: {
|
|
399
|
+
}, 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
400
|
width: "100%",
|
|
398
401
|
padding: "0.5rem",
|
|
399
402
|
boxSizing: "border-box",
|
package/package.json
CHANGED