@megha-ui/react 1.2.281 → 1.2.282
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.
|
@@ -568,9 +568,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
568
568
|
setGridGroupBy(groupBy);
|
|
569
569
|
}
|
|
570
570
|
}, [gridColumns, groupBy]);
|
|
571
|
-
const groupByMultipleKeys = (data, groupByKeys) => {
|
|
572
|
-
// When compositeGroupBy is enabled and multiple keys are selected,
|
|
573
|
-
// treat the selected keys as a single composite grouping (one level)
|
|
571
|
+
const groupByMultipleKeys = (data, groupByKeys, compositeGroupBy = false) => {
|
|
574
572
|
if (compositeGroupBy && groupByKeys.length > 1) {
|
|
575
573
|
const groupsMap = new Map();
|
|
576
574
|
const allKeys = groupByKeys.filter((k) => k);
|
|
@@ -578,7 +576,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
578
576
|
data.forEach((item) => {
|
|
579
577
|
const values = allKeys.map((k) => { var _a, _b; return (_b = (_a = item[k]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""; });
|
|
580
578
|
const compositeValue = values.join(">");
|
|
581
|
-
const key = compositeValue;
|
|
579
|
+
const key = compositeValue;
|
|
582
580
|
if (!groupsMap.has(key)) {
|
|
583
581
|
groupsMap.set(key, {
|
|
584
582
|
key: lastKey,
|
|
@@ -595,12 +593,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
595
593
|
const groupedResult = Array.from(groupsMap.values());
|
|
596
594
|
groupedResult.forEach((group) => {
|
|
597
595
|
group.count = group.values.length;
|
|
598
|
-
// Put items as subGroups so the flattener emits the row items
|
|
599
596
|
group.subGroups = group.values;
|
|
600
597
|
});
|
|
601
598
|
return groupedResult;
|
|
602
599
|
}
|
|
603
|
-
// Default behavior: nested grouping by each key level-by-level
|
|
604
600
|
const groupData = (items, keys, level = 0) => {
|
|
605
601
|
if (level >= keys.length)
|
|
606
602
|
return items;
|
|
@@ -676,7 +672,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
676
672
|
.split(",")
|
|
677
673
|
.map((s) => s.trim())
|
|
678
674
|
.filter((s) => s);
|
|
679
|
-
const groupedArray = sets.length ? groupByMultipleKeys(sortedData, sets) : [];
|
|
675
|
+
const groupedArray = sets.length ? groupByMultipleKeys(sortedData, sets, compositeGroupBy) : [];
|
|
680
676
|
const flatGroupedArray = flattenGroupedData(groupedArray, 1);
|
|
681
677
|
setGroupedData(flatGroupedArray);
|
|
682
678
|
const grouped = flatGroupedArray
|
package/package.json
CHANGED