@megha-ui/react 1.3.48 → 1.3.50

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.
@@ -46,15 +46,28 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
46
46
  return null;
47
47
  };
48
48
  const calculateAutoPosition = () => {
49
+ var _a, _b;
49
50
  if (!wrapperRef.current)
50
51
  return;
51
52
  const rect = wrapperRef.current.getBoundingClientRect();
52
- const bottomSpace = window.innerHeight - rect.bottom;
53
- const topSpace = rect.top;
54
- const heightNum = typeof maxDropdownHeight === "number"
53
+ const boundaryParent = getLayoutBoundaryParent(wrapperRef.current);
54
+ const containerRect = boundaryParent === null || boundaryParent === void 0 ? void 0 : boundaryParent.getBoundingClientRect();
55
+ const containerTop = (_a = containerRect === null || containerRect === void 0 ? void 0 : containerRect.top) !== null && _a !== void 0 ? _a : 0;
56
+ const containerBottom = (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.bottom) !== null && _b !== void 0 ? _b : window.innerHeight;
57
+ const viewportPadding = 8;
58
+ const menuGap = 8;
59
+ const minUsefulHeight = 180;
60
+ const preferredMaxHeight = typeof maxDropdownHeight === "number"
55
61
  ? maxDropdownHeight
56
62
  : parseInt(`${maxDropdownHeight}`, 10) || 200;
57
- if (bottomSpace < heightNum && topSpace > bottomSpace) {
63
+ const rawSpaceBelow = containerBottom - rect.bottom - viewportPadding - menuGap;
64
+ const rawSpaceAbove = rect.top - containerTop - viewportPadding - menuGap;
65
+ const spaceBelow = Math.max(0, Math.floor(rawSpaceBelow));
66
+ const spaceAbove = Math.max(0, Math.floor(rawSpaceAbove));
67
+ const shouldOpenTop = spaceBelow < minUsefulHeight && spaceAbove > spaceBelow;
68
+ const available = shouldOpenTop ? spaceAbove : spaceBelow;
69
+ const resolvedMax = Math.min(available, preferredMaxHeight);
70
+ if (shouldOpenTop) {
58
71
  setClickStyle({ left: 0, bottom: "100%" });
59
72
  }
60
73
  else {
@@ -84,8 +97,14 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
84
97
  rect.bottom -
85
98
  viewportPadding -
86
99
  menuGap -
87
- searchHeight - applyBtnHeight;
88
- const rawSpaceAbove = rect.top - containerTop - viewportPadding - menuGap - searchHeight - applyBtnHeight;
100
+ searchHeight -
101
+ applyBtnHeight;
102
+ const rawSpaceAbove = rect.top -
103
+ containerTop -
104
+ viewportPadding -
105
+ menuGap -
106
+ searchHeight -
107
+ applyBtnHeight;
89
108
  const spaceBelow = Math.max(0, Math.floor(rawSpaceBelow));
90
109
  const spaceAbove = Math.max(0, Math.floor(rawSpaceAbove));
91
110
  const opensUpwards = typeof clickStyle.bottom !== "undefined";
@@ -163,7 +163,7 @@ const NewSummariseDetails = ({ columns, rowIndex, groupBy, sortable, cellStyle,
163
163
  ? `${groupedData}>>${column.key}`
164
164
  : column.key;
165
165
  if (!column.hidden) {
166
- return (_jsxs("div", { className: `${sortable && column.sortable ? "sortable" : ""} ${column.showMenu ? "menu-true" : "menu-false"} ${`column-${column.key}`} ${columnKey}-${(_a = summariseDetails[columnKey]) === null || _a === void 0 ? void 0 : _a.type}`, style: Object.assign(Object.assign({}, cellStyle), { position: "relative", padding: "0.5rem", textAlign: "left", whiteSpace: "nowrap", textOverflow: "ellipsis", flex: widthMode === "auto" ? 1 : undefined, flexGrow: widthMode === "auto" ? 1 : 0, flexShrink: widthMode === "auto" ? 1 : 0, background: "var(--row-header-bg)" }), children: [summariseDetails[columnKey] &&
166
+ return (_jsxs("div", { className: `${sortable && column.sortable ? "sortable" : ""} ${column.showMenu ? "menu-true" : "menu-false"} ${`column-${column.key}`} ${columnKey}-${(_a = summariseDetails[columnKey]) === null || _a === void 0 ? void 0 : _a.type}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, cellStyle), { position: groupBy !== "" ? "relative" : "sticky" }), (groupBy !== "" ? {} : { top: 0 })), { padding: "0.5rem", textAlign: "left", whiteSpace: "nowrap", textOverflow: "ellipsis", flex: widthMode === "auto" ? 1 : undefined, flexGrow: widthMode === "auto" ? 1 : 0, flexShrink: widthMode === "auto" ? 1 : 0, background: "var(--row-header-bg)" }), children: [summariseDetails[columnKey] &&
167
167
  summariseDetails[columnKey].type ? (_jsxs("div", { style: {
168
168
  display: "flex",
169
169
  alignItems: "center",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.3.48",
3
+ "version": "1.3.50",
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",