@megha-ui/react 1.3.44 → 1.3.46
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.
|
@@ -19,6 +19,7 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
19
19
|
const clearIconRef = useRef(null);
|
|
20
20
|
const searchInputRef = useRef(null);
|
|
21
21
|
const searchOptionRef = useRef(null);
|
|
22
|
+
const applyButtonRef = useRef(null);
|
|
22
23
|
const optionRefs = useRef([]);
|
|
23
24
|
const [highlightIndex, setHighlightIndex] = useState(0);
|
|
24
25
|
const [intermediateValues, setIntermediateValues] = useState(selectedValues);
|
|
@@ -64,30 +65,27 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
64
65
|
setIntermediateValues(selectedValues);
|
|
65
66
|
}, [selectedValues]);
|
|
66
67
|
useEffect(() => {
|
|
67
|
-
var _a, _b, _c, _d, _e;
|
|
68
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
68
69
|
if (isOpen && searchEnabled) {
|
|
69
70
|
(_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
70
|
-
if (typeof maxDropdownHeight === "undefined" &&
|
|
71
|
-
wrapperRef.current) {
|
|
71
|
+
if (typeof maxDropdownHeight === "undefined" && wrapperRef.current) {
|
|
72
72
|
const rect = wrapperRef.current.getBoundingClientRect();
|
|
73
73
|
const searchOptionRect = (_b = searchOptionRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
74
|
-
const
|
|
74
|
+
const applyButtonRect = (_c = applyButtonRef.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
|
|
75
|
+
const searchHeight = (_d = searchOptionRect === null || searchOptionRect === void 0 ? void 0 : searchOptionRect.height) !== null && _d !== void 0 ? _d : 0;
|
|
76
|
+
const applyBtnHeight = (_e = applyButtonRect === null || applyButtonRect === void 0 ? void 0 : applyButtonRect.height) !== null && _e !== void 0 ? _e : 0;
|
|
75
77
|
const boundaryParent = getLayoutBoundaryParent(wrapperRef.current);
|
|
76
78
|
const containerRect = boundaryParent === null || boundaryParent === void 0 ? void 0 : boundaryParent.getBoundingClientRect();
|
|
77
|
-
const containerTop = (
|
|
78
|
-
const containerBottom = (
|
|
79
|
+
const containerTop = (_f = containerRect === null || containerRect === void 0 ? void 0 : containerRect.top) !== null && _f !== void 0 ? _f : 0;
|
|
80
|
+
const containerBottom = (_g = containerRect === null || containerRect === void 0 ? void 0 : containerRect.bottom) !== null && _g !== void 0 ? _g : document.documentElement.clientHeight;
|
|
79
81
|
const viewportPadding = 8;
|
|
80
82
|
const menuGap = 8;
|
|
81
83
|
const rawSpaceBelow = containerBottom -
|
|
82
84
|
rect.bottom -
|
|
83
85
|
viewportPadding -
|
|
84
86
|
menuGap -
|
|
85
|
-
searchHeight;
|
|
86
|
-
const rawSpaceAbove = rect.top -
|
|
87
|
-
containerTop -
|
|
88
|
-
viewportPadding -
|
|
89
|
-
menuGap -
|
|
90
|
-
searchHeight;
|
|
87
|
+
searchHeight - applyBtnHeight;
|
|
88
|
+
const rawSpaceAbove = rect.top - containerTop - viewportPadding - menuGap - searchHeight - applyBtnHeight;
|
|
91
89
|
const spaceBelow = Math.max(0, Math.floor(rawSpaceBelow));
|
|
92
90
|
const spaceAbove = Math.max(0, Math.floor(rawSpaceAbove));
|
|
93
91
|
const opensUpwards = typeof clickStyle.bottom !== "undefined";
|
|
@@ -516,7 +514,7 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
516
514
|
justifyContent: "end",
|
|
517
515
|
padding: "0.75rem 0.5rem",
|
|
518
516
|
borderTop: "1px solid var(--divider, #f5f5f5)",
|
|
519
|
-
}, children: _jsx(Button, { text: "Apply", fontSize: "", fontWeight: "", color: "#FFFFFF", backgroundColor: "#2377BA", borderColor: "#2377BA", onClick: () => {
|
|
517
|
+
}, ref: applyButtonRef, children: _jsx(Button, { text: "Apply", fontSize: "", fontWeight: "", color: "#FFFFFF", backgroundColor: "#2377BA", borderColor: "#2377BA", onClick: () => {
|
|
520
518
|
onApplyChange(intermediateValues);
|
|
521
519
|
setIsOpen(false);
|
|
522
520
|
}, borderRadius: "0.5rem" }) }))] })] })] }));
|
|
@@ -1118,6 +1118,12 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1118
1118
|
});
|
|
1119
1119
|
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), filterObj)));
|
|
1120
1120
|
};
|
|
1121
|
+
const normalizeFixedFilters = (filters) => {
|
|
1122
|
+
return Object.entries(filters)
|
|
1123
|
+
.map(([key, values]) => `${key}:${[...values].sort().join(",")}`)
|
|
1124
|
+
.sort()
|
|
1125
|
+
.join("|");
|
|
1126
|
+
};
|
|
1121
1127
|
const filterDetails = useMemo(() => {
|
|
1122
1128
|
const filterColumn = gridColumns.reduce((acc, column) => {
|
|
1123
1129
|
const query = searchQueries[column.key];
|
|
@@ -1134,6 +1140,13 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1134
1140
|
}
|
|
1135
1141
|
return acc;
|
|
1136
1142
|
}, {});
|
|
1143
|
+
const fixedFilterColumn = fixedColumns.reduce((acc, column) => {
|
|
1144
|
+
const values = fixedFilterValues[column.key] || [];
|
|
1145
|
+
if (values.length > 0) {
|
|
1146
|
+
acc[column.key] = values;
|
|
1147
|
+
}
|
|
1148
|
+
return acc;
|
|
1149
|
+
}, {});
|
|
1137
1150
|
const propFilterColumn = gridColumns.reduce((acc, column) => {
|
|
1138
1151
|
if (filterData) {
|
|
1139
1152
|
const { searchQueries, uniqueSearch } = filterData;
|
|
@@ -1153,6 +1166,14 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1153
1166
|
}
|
|
1154
1167
|
return acc;
|
|
1155
1168
|
}, {});
|
|
1169
|
+
const propFixedFilterColumn = fixedColumns.reduce((acc, column) => {
|
|
1170
|
+
var _a;
|
|
1171
|
+
const values = (filterData && ((_a = filterData.fixedFilterValues) === null || _a === void 0 ? void 0 : _a[column.key])) || [];
|
|
1172
|
+
if (values.length > 0) {
|
|
1173
|
+
acc[column.key] = values;
|
|
1174
|
+
}
|
|
1175
|
+
return acc;
|
|
1176
|
+
}, {});
|
|
1156
1177
|
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1157
1178
|
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
1158
1179
|
if (query) {
|
|
@@ -1167,7 +1188,9 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1167
1188
|
}
|
|
1168
1189
|
return acc;
|
|
1169
1190
|
}, {});
|
|
1170
|
-
const hasFilters = Object.keys(filterColumn).length > 0 ||
|
|
1191
|
+
const hasFilters = Object.keys(filterColumn).length > 0 ||
|
|
1192
|
+
globalInputSearch !== "" ||
|
|
1193
|
+
Object.keys(fixedFilterColumn).length > 0;
|
|
1171
1194
|
return {
|
|
1172
1195
|
hasFilters,
|
|
1173
1196
|
filtersUpdated: Object.keys(filterColumn).sort().toString() !==
|
|
@@ -1178,9 +1201,22 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1178
1201
|
Object.keys(propSortColumn).sort().toString() ||
|
|
1179
1202
|
Object.values(sortColumn).sort().toString() !==
|
|
1180
1203
|
Object.values(propSortColumn).sort().toString() ||
|
|
1204
|
+
normalizeFixedFilters(fixedFilterColumn) !==
|
|
1205
|
+
normalizeFixedFilters(propFixedFilterColumn) ||
|
|
1181
1206
|
(filterData === null || filterData === void 0 ? void 0 : filterData.globalInputSearch) !== globalInputSearch,
|
|
1182
1207
|
};
|
|
1183
|
-
}, [
|
|
1208
|
+
}, [
|
|
1209
|
+
searchQueries,
|
|
1210
|
+
globalInputSearch,
|
|
1211
|
+
uniqueSearch,
|
|
1212
|
+
gridColumns,
|
|
1213
|
+
filteredData,
|
|
1214
|
+
fixedFilterValues,
|
|
1215
|
+
fixedColumns,
|
|
1216
|
+
sortQueries,
|
|
1217
|
+
defaultSort,
|
|
1218
|
+
filterData,
|
|
1219
|
+
]);
|
|
1184
1220
|
const sortDetails = useMemo(() => {
|
|
1185
1221
|
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1186
1222
|
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
@@ -1469,6 +1505,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1469
1505
|
groupBy: gridGroupBy,
|
|
1470
1506
|
sortQueries: sortQueries,
|
|
1471
1507
|
summariseKeys: summariseKeys,
|
|
1508
|
+
fixedFilterValues,
|
|
1472
1509
|
}), style: {
|
|
1473
1510
|
marginLeft: 6,
|
|
1474
1511
|
cursor: "pointer",
|
package/package.json
CHANGED