@megha-ui/react 1.3.120 → 1.3.122
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.
- package/dist/components/grid/index.js +108 -101
- package/package.json +1 -1
|
@@ -1014,6 +1014,12 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1014
1014
|
return item;
|
|
1015
1015
|
}));
|
|
1016
1016
|
};
|
|
1017
|
+
const normalizeFixedFilters = (filters) => {
|
|
1018
|
+
return Object.entries(filters)
|
|
1019
|
+
.map(([key, values]) => `${key}:${[...values].sort().join(",")}`)
|
|
1020
|
+
.sort()
|
|
1021
|
+
.join("|");
|
|
1022
|
+
};
|
|
1017
1023
|
const updateRowOpened = (key) => {
|
|
1018
1024
|
let updatedRowOpened = rowOpened;
|
|
1019
1025
|
if (updatedRowOpened.includes(key)) {
|
|
@@ -1025,6 +1031,107 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1025
1031
|
setRowOpened(updatedRowOpened);
|
|
1026
1032
|
setOpenedRows && setOpenedRows(updatedRowOpened);
|
|
1027
1033
|
};
|
|
1034
|
+
const filterDetails = useMemo(() => {
|
|
1035
|
+
const filterColumn = gridColumns.reduce((acc, column) => {
|
|
1036
|
+
const query = searchQueries[column.key];
|
|
1037
|
+
const uniqeValues = [
|
|
1038
|
+
...new Set(filteredData.map((data) => { var _a; return data[column.key] && ((_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()); })),
|
|
1039
|
+
].sort();
|
|
1040
|
+
if (query &&
|
|
1041
|
+
(query.text !== "" || query.type !== defaultSearchOperation)) {
|
|
1042
|
+
acc[column.key] = query.text;
|
|
1043
|
+
}
|
|
1044
|
+
else if (uniqueSearch[column.key] &&
|
|
1045
|
+
uniqeValues.toString() !== uniqueSearch[column.key].sort().toString()) {
|
|
1046
|
+
acc[column.key] = uniqueSearch[column.key].join(",");
|
|
1047
|
+
}
|
|
1048
|
+
return acc;
|
|
1049
|
+
}, {});
|
|
1050
|
+
const fixedFilterColumn = fixedColumns.reduce((acc, column) => {
|
|
1051
|
+
const values = fixedFilterValues[column.key] || [];
|
|
1052
|
+
if (values.length > 0) {
|
|
1053
|
+
acc[column.key] = values;
|
|
1054
|
+
}
|
|
1055
|
+
return acc;
|
|
1056
|
+
}, {});
|
|
1057
|
+
const propFilterColumn = gridColumns.reduce((acc, column) => {
|
|
1058
|
+
if (filterData) {
|
|
1059
|
+
const { searchQueries, uniqueSearch } = filterData;
|
|
1060
|
+
const query = searchQueries[column.key];
|
|
1061
|
+
const uniqeValues = [
|
|
1062
|
+
...new Set(filteredData.map((data) => { var _a; return data[column.key] && ((_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()); })),
|
|
1063
|
+
].sort();
|
|
1064
|
+
if (query &&
|
|
1065
|
+
(query.text !== "" || query.type !== defaultSearchOperation)) {
|
|
1066
|
+
acc[column.key] = query.text;
|
|
1067
|
+
}
|
|
1068
|
+
else if (uniqueSearch[column.key] &&
|
|
1069
|
+
uniqeValues.toString() !==
|
|
1070
|
+
uniqueSearch[column.key].sort().toString()) {
|
|
1071
|
+
acc[column.key] = uniqueSearch[column.key].join(",");
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return acc;
|
|
1075
|
+
}, {});
|
|
1076
|
+
const propFixedFilterColumn = fixedColumns.reduce((acc, column) => {
|
|
1077
|
+
var _a;
|
|
1078
|
+
const values = (filterData && ((_a = filterData.fixedFilterValues) === null || _a === void 0 ? void 0 : _a[column.key])) || [];
|
|
1079
|
+
if (values.length > 0) {
|
|
1080
|
+
acc[column.key] = values;
|
|
1081
|
+
}
|
|
1082
|
+
return acc;
|
|
1083
|
+
}, {});
|
|
1084
|
+
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1085
|
+
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
1086
|
+
if (query) {
|
|
1087
|
+
acc[column.key] = query;
|
|
1088
|
+
}
|
|
1089
|
+
return acc;
|
|
1090
|
+
}, {});
|
|
1091
|
+
const propSortColumn = gridColumns.reduce((acc, column) => {
|
|
1092
|
+
const query = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort[column.key];
|
|
1093
|
+
if (query) {
|
|
1094
|
+
acc[column.key] = query;
|
|
1095
|
+
}
|
|
1096
|
+
return acc;
|
|
1097
|
+
}, {});
|
|
1098
|
+
const hasFilters = Object.keys(filterColumn).length > 0 ||
|
|
1099
|
+
globalInputSearch !== "" ||
|
|
1100
|
+
Object.keys(fixedFilterColumn).length > 0;
|
|
1101
|
+
return {
|
|
1102
|
+
hasFilters,
|
|
1103
|
+
filtersUpdated: Object.keys(filterColumn).sort().toString() !==
|
|
1104
|
+
Object.keys(propFilterColumn).sort().toString() ||
|
|
1105
|
+
Object.values(filterColumn).sort().toString() !==
|
|
1106
|
+
Object.values(propFilterColumn).sort().toString() ||
|
|
1107
|
+
Object.keys(sortColumn).sort().toString() !==
|
|
1108
|
+
Object.keys(propSortColumn).sort().toString() ||
|
|
1109
|
+
Object.values(sortColumn).sort().toString() !==
|
|
1110
|
+
Object.values(propSortColumn).sort().toString() ||
|
|
1111
|
+
normalizeFixedFilters(fixedFilterColumn) !==
|
|
1112
|
+
normalizeFixedFilters(propFixedFilterColumn) ||
|
|
1113
|
+
(filterData === null || filterData === void 0 ? void 0 : filterData.globalInputSearch) !== globalInputSearch,
|
|
1114
|
+
};
|
|
1115
|
+
}, [
|
|
1116
|
+
searchQueries,
|
|
1117
|
+
globalInputSearch,
|
|
1118
|
+
uniqueSearch,
|
|
1119
|
+
gridColumns,
|
|
1120
|
+
filteredData,
|
|
1121
|
+
fixedFilterValues,
|
|
1122
|
+
fixedColumns,
|
|
1123
|
+
sortQueries,
|
|
1124
|
+
defaultSort,
|
|
1125
|
+
filterData,
|
|
1126
|
+
]);
|
|
1127
|
+
const shouldShowHeaderActionsSpacer = isSummarise ||
|
|
1128
|
+
showHideAvailable ||
|
|
1129
|
+
exportAvailable ||
|
|
1130
|
+
isHideDupsAvailable ||
|
|
1131
|
+
fullScreen ||
|
|
1132
|
+
freezeColumnsAvailable ||
|
|
1133
|
+
filterDetails.filtersUpdated ||
|
|
1134
|
+
hasCustomOperation;
|
|
1028
1135
|
useEffect(() => {
|
|
1029
1136
|
if (showHideAvailable ||
|
|
1030
1137
|
exportAvailable ||
|
|
@@ -1122,105 +1229,6 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1122
1229
|
});
|
|
1123
1230
|
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), filterObj)));
|
|
1124
1231
|
};
|
|
1125
|
-
const normalizeFixedFilters = (filters) => {
|
|
1126
|
-
return Object.entries(filters)
|
|
1127
|
-
.map(([key, values]) => `${key}:${[...values].sort().join(",")}`)
|
|
1128
|
-
.sort()
|
|
1129
|
-
.join("|");
|
|
1130
|
-
};
|
|
1131
|
-
const filterDetails = useMemo(() => {
|
|
1132
|
-
const filterColumn = gridColumns.reduce((acc, column) => {
|
|
1133
|
-
const query = searchQueries[column.key];
|
|
1134
|
-
const uniqeValues = [
|
|
1135
|
-
...new Set(filteredData.map((data) => { var _a; return data[column.key] && ((_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()); })),
|
|
1136
|
-
].sort();
|
|
1137
|
-
if (query &&
|
|
1138
|
-
(query.text !== "" || query.type !== defaultSearchOperation)) {
|
|
1139
|
-
acc[column.key] = query.text;
|
|
1140
|
-
}
|
|
1141
|
-
else if (uniqueSearch[column.key] &&
|
|
1142
|
-
uniqeValues.toString() !== uniqueSearch[column.key].sort().toString()) {
|
|
1143
|
-
acc[column.key] = uniqueSearch[column.key].join(",");
|
|
1144
|
-
}
|
|
1145
|
-
return acc;
|
|
1146
|
-
}, {});
|
|
1147
|
-
const fixedFilterColumn = fixedColumns.reduce((acc, column) => {
|
|
1148
|
-
const values = fixedFilterValues[column.key] || [];
|
|
1149
|
-
if (values.length > 0) {
|
|
1150
|
-
acc[column.key] = values;
|
|
1151
|
-
}
|
|
1152
|
-
return acc;
|
|
1153
|
-
}, {});
|
|
1154
|
-
const propFilterColumn = gridColumns.reduce((acc, column) => {
|
|
1155
|
-
if (filterData) {
|
|
1156
|
-
const { searchQueries, uniqueSearch } = filterData;
|
|
1157
|
-
const query = searchQueries[column.key];
|
|
1158
|
-
const uniqeValues = [
|
|
1159
|
-
...new Set(filteredData.map((data) => { var _a; return data[column.key] && ((_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()); })),
|
|
1160
|
-
].sort();
|
|
1161
|
-
if (query &&
|
|
1162
|
-
(query.text !== "" || query.type !== defaultSearchOperation)) {
|
|
1163
|
-
acc[column.key] = query.text;
|
|
1164
|
-
}
|
|
1165
|
-
else if (uniqueSearch[column.key] &&
|
|
1166
|
-
uniqeValues.toString() !==
|
|
1167
|
-
uniqueSearch[column.key].sort().toString()) {
|
|
1168
|
-
acc[column.key] = uniqueSearch[column.key].join(",");
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
return acc;
|
|
1172
|
-
}, {});
|
|
1173
|
-
const propFixedFilterColumn = fixedColumns.reduce((acc, column) => {
|
|
1174
|
-
var _a;
|
|
1175
|
-
const values = (filterData && ((_a = filterData.fixedFilterValues) === null || _a === void 0 ? void 0 : _a[column.key])) || [];
|
|
1176
|
-
if (values.length > 0) {
|
|
1177
|
-
acc[column.key] = values;
|
|
1178
|
-
}
|
|
1179
|
-
return acc;
|
|
1180
|
-
}, {});
|
|
1181
|
-
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1182
|
-
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
1183
|
-
if (query) {
|
|
1184
|
-
acc[column.key] = query;
|
|
1185
|
-
}
|
|
1186
|
-
return acc;
|
|
1187
|
-
}, {});
|
|
1188
|
-
const propSortColumn = gridColumns.reduce((acc, column) => {
|
|
1189
|
-
const query = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort[column.key];
|
|
1190
|
-
if (query) {
|
|
1191
|
-
acc[column.key] = query;
|
|
1192
|
-
}
|
|
1193
|
-
return acc;
|
|
1194
|
-
}, {});
|
|
1195
|
-
const hasFilters = Object.keys(filterColumn).length > 0 ||
|
|
1196
|
-
globalInputSearch !== "" ||
|
|
1197
|
-
Object.keys(fixedFilterColumn).length > 0;
|
|
1198
|
-
return {
|
|
1199
|
-
hasFilters,
|
|
1200
|
-
filtersUpdated: Object.keys(filterColumn).sort().toString() !==
|
|
1201
|
-
Object.keys(propFilterColumn).sort().toString() ||
|
|
1202
|
-
Object.values(filterColumn).sort().toString() !==
|
|
1203
|
-
Object.values(propFilterColumn).sort().toString() ||
|
|
1204
|
-
Object.keys(sortColumn).sort().toString() !==
|
|
1205
|
-
Object.keys(propSortColumn).sort().toString() ||
|
|
1206
|
-
Object.values(sortColumn).sort().toString() !==
|
|
1207
|
-
Object.values(propSortColumn).sort().toString() ||
|
|
1208
|
-
normalizeFixedFilters(fixedFilterColumn) !==
|
|
1209
|
-
normalizeFixedFilters(propFixedFilterColumn) ||
|
|
1210
|
-
(filterData === null || filterData === void 0 ? void 0 : filterData.globalInputSearch) !== globalInputSearch,
|
|
1211
|
-
};
|
|
1212
|
-
}, [
|
|
1213
|
-
searchQueries,
|
|
1214
|
-
globalInputSearch,
|
|
1215
|
-
uniqueSearch,
|
|
1216
|
-
gridColumns,
|
|
1217
|
-
filteredData,
|
|
1218
|
-
fixedFilterValues,
|
|
1219
|
-
fixedColumns,
|
|
1220
|
-
sortQueries,
|
|
1221
|
-
defaultSort,
|
|
1222
|
-
filterData,
|
|
1223
|
-
]);
|
|
1224
1232
|
const sortDetails = useMemo(() => {
|
|
1225
1233
|
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1226
1234
|
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
@@ -1332,7 +1340,6 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1332
1340
|
// setGridGroupBy(groupBy);
|
|
1333
1341
|
// }
|
|
1334
1342
|
// };
|
|
1335
|
-
console.log({ isHideDupsAvailable });
|
|
1336
1343
|
const gridBody = (_jsxs("div", { style: {
|
|
1337
1344
|
height: withCard ? "100%" : height,
|
|
1338
1345
|
backgroundColor: isFullScreen ? "var(--background)" : "transparent",
|
|
@@ -1493,7 +1500,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1493
1500
|
: undefined, isSort: column.fixedFilterOrder ? false : undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 flex-1", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
|
|
1494
1501
|
}
|
|
1495
1502
|
return null;
|
|
1496
|
-
}), _jsx("div", { className: "flex-1 h-2" }), isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
|
|
1503
|
+
}), shouldShowHeaderActionsSpacer && _jsx("div", { className: "flex-1 h-2" }), isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
|
|
1497
1504
|
cursor: "pointer",
|
|
1498
1505
|
marginLeft: "0.75rem",
|
|
1499
1506
|
}, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? (_jsx(TbCalculatorFilled, { color: summarizeColor, size: 18 })) : (_jsx(TbCalculator, { size: 18 })) })), showHideAvailable && (_jsx("div", { onClick: openSetting, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: SettingIcon ? SettingIcon : _jsx(FiEye, { size: 18 }) })), exportAvailable && (_jsx("div", { onClick: handleExport, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: ExportIcon ? ExportIcon : _jsx(FiShare, { size: 16 }) })), isHideDupsAvailable && (_jsx("div", { onClick: () => setHideDuplicates((prev) => !prev), style: { cursor: "pointer", marginLeft: "0.75rem" }, title: hideDuplicates ? "Show Duplicates" : "Hide Duplicates", children: hideDuplicates ? (_jsx(MdLayers, { size: 18 })) : (_jsx(MdLayersClear, { size: 18 })) })), fullScreen && (_jsx("div", { onClick: toggleFullScreen, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: isFullScreen ? (_jsx(MdFullscreenExit, { size: 20 })) : (_jsx(MdFullscreen, { size: 20 })) })), freezeColumnsAvailable && (_jsx("div", { onClick: toggleCollapse, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: isCollapsed ? (_jsx(FiChevronsRight, { size: 20 })) : (_jsx(FiChevronsLeft, { size: 20 })) })), (filterDetails.filtersUpdated ||
|
package/package.json
CHANGED