@megha-ui/react 1.2.350 → 1.2.352
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.
|
@@ -569,38 +569,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
569
569
|
}
|
|
570
570
|
}, [gridColumns, groupBy]);
|
|
571
571
|
const groupByMultipleKeys = (data, groupByKeys) => {
|
|
572
|
-
// Backward compatibility: if compositeGroupBy is true and no '+' is used,
|
|
573
|
-
// and more than one key is provided, group all keys into a single composite bucket.
|
|
574
|
-
const hasPlus = groupByKeys.some((k) => k === null || k === void 0 ? void 0 : k.includes("+"));
|
|
575
|
-
if (groupByKeys.length > 1 && !hasPlus) {
|
|
576
|
-
const groupsMap = new Map();
|
|
577
|
-
const allKeys = groupByKeys.filter((k) => k);
|
|
578
|
-
const lastKey = allKeys[allKeys.length - 1];
|
|
579
|
-
data.forEach((item) => {
|
|
580
|
-
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 : ""; });
|
|
581
|
-
const compositeValue = values.join("+");
|
|
582
|
-
const key = compositeValue;
|
|
583
|
-
if (!groupsMap.has(key)) {
|
|
584
|
-
groupsMap.set(key, {
|
|
585
|
-
key: lastKey,
|
|
586
|
-
value: compositeValue,
|
|
587
|
-
count: 0,
|
|
588
|
-
subGroups: [],
|
|
589
|
-
values: [],
|
|
590
|
-
allKeys: allKeys,
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
const group = groupsMap.get(key);
|
|
594
|
-
group.values.push(item);
|
|
595
|
-
});
|
|
596
|
-
const groupedResult = Array.from(groupsMap.values());
|
|
597
|
-
groupedResult.forEach((group) => {
|
|
598
|
-
group.count = group.values.length;
|
|
599
|
-
group.subGroups = group.values;
|
|
600
|
-
});
|
|
601
|
-
return groupedResult;
|
|
602
|
-
}
|
|
603
|
-
// Parse keys into levels, where each level can be a composite (split by '+')
|
|
604
572
|
const parsedKeys = groupByKeys
|
|
605
573
|
.map((k) => (k !== null && k !== void 0 ? k : "").trim())
|
|
606
574
|
.filter((k) => k)
|
|
@@ -610,7 +578,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
610
578
|
.map((s) => s.trim())
|
|
611
579
|
.filter(Boolean)
|
|
612
580
|
: [k]);
|
|
613
|
-
console.log(parsedKeys);
|
|
614
581
|
const groupData = (items, keys, level = 0) => {
|
|
615
582
|
if (level >= keys.length)
|
|
616
583
|
return items;
|
|
@@ -44,7 +44,6 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
|
|
|
44
44
|
})
|
|
45
45
|
.map((item, gIndex) => {
|
|
46
46
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
47
|
-
console.log({ item });
|
|
48
47
|
if (gIndex >= startIndex && gIndex <= endIndex)
|
|
49
48
|
return item.type === "main" ? (_jsxs("div", { style: {
|
|
50
49
|
width: "100%",
|
|
@@ -103,7 +102,6 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
|
|
|
103
102
|
: compositeIndex > -1
|
|
104
103
|
? compositeValues[compositeIndex]
|
|
105
104
|
: "";
|
|
106
|
-
console.log({ compositeIndex, idx, columnKey });
|
|
107
105
|
if (display && idx === keys.length - 1) {
|
|
108
106
|
return `${display} (${item === null || item === void 0 ? void 0 : item.count})`;
|
|
109
107
|
}
|
package/package.json
CHANGED