@megha-ui/react 1.2.264 → 1.2.266
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.
|
@@ -670,52 +670,13 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
670
670
|
}
|
|
671
671
|
return flatArray;
|
|
672
672
|
};
|
|
673
|
-
// Support grouping by comma-separated sets, where each set may contain
|
|
674
|
-
// multiple keys separated by "+" to indicate a composite group at that level.
|
|
675
|
-
const groupBySets = (data, groupSets) => {
|
|
676
|
-
const groupLevel = (items, level) => {
|
|
677
|
-
if (level >= groupSets.length)
|
|
678
|
-
return items;
|
|
679
|
-
const keys = groupSets[level];
|
|
680
|
-
const map = new Map();
|
|
681
|
-
const lastKey = keys[keys.length - 1];
|
|
682
|
-
items.forEach((item) => {
|
|
683
|
-
const values = keys.map((k) => { var _a, _b; return (_b = (_a = item[k]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""; });
|
|
684
|
-
const composite = values.join(">");
|
|
685
|
-
if (!map.has(composite)) {
|
|
686
|
-
map.set(composite, {
|
|
687
|
-
key: lastKey,
|
|
688
|
-
value: composite,
|
|
689
|
-
count: 0,
|
|
690
|
-
subGroups: [],
|
|
691
|
-
values: [],
|
|
692
|
-
allKeys: keys,
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
const g = map.get(composite);
|
|
696
|
-
g.values.push(item);
|
|
697
|
-
});
|
|
698
|
-
const groups = Array.from(map.values());
|
|
699
|
-
console.log({ groups });
|
|
700
|
-
groups.forEach((g) => {
|
|
701
|
-
g.count = g.values.length;
|
|
702
|
-
g.subGroups = groupLevel(g.values, level + 1);
|
|
703
|
-
});
|
|
704
|
-
return groups;
|
|
705
|
-
};
|
|
706
|
-
return groupLevel(data, 0);
|
|
707
|
-
};
|
|
708
673
|
useEffect(() => {
|
|
709
674
|
if (gridGroupBy && gridGroupBy !== "") {
|
|
710
675
|
const sets = gridGroupBy
|
|
711
676
|
.split(",")
|
|
712
677
|
.map((s) => s.trim())
|
|
713
|
-
.filter((s) => s)
|
|
714
|
-
|
|
715
|
-
.split("+")
|
|
716
|
-
.map((k) => k.trim())
|
|
717
|
-
.filter((k) => k));
|
|
718
|
-
const groupedArray = sets.length ? groupBySets(sortedData, sets) : [];
|
|
678
|
+
.filter((s) => s);
|
|
679
|
+
const groupedArray = sets.length ? groupByMultipleKeys(sortedData, sets) : [];
|
|
719
680
|
console.log(groupedArray);
|
|
720
681
|
const flatGroupedArray = flattenGroupedData(groupedArray, 1);
|
|
721
682
|
setGroupedData(flatGroupedArray);
|
package/package.json
CHANGED