@megha-ui/react 1.2.336 → 1.2.338
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.
|
@@ -570,8 +570,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
570
570
|
}
|
|
571
571
|
}, [gridColumns, groupBy]);
|
|
572
572
|
const groupByMultipleKeys = (data, groupByKeys) => {
|
|
573
|
-
// Backward compatibility: if compositeGroupBy is true and no '+' is used,
|
|
574
|
-
// and more than one key is provided, group all keys into a single composite bucket.
|
|
575
573
|
const hasPlus = groupByKeys.some((k) => k === null || k === void 0 ? void 0 : k.includes("+"));
|
|
576
574
|
if (groupByKeys.length > 1 && !hasPlus) {
|
|
577
575
|
const groupsMap = new Map();
|
|
@@ -601,7 +599,6 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
601
599
|
});
|
|
602
600
|
return groupedResult;
|
|
603
601
|
}
|
|
604
|
-
// Parse keys into levels, where each level can be a composite (split by '+')
|
|
605
602
|
const parsedKeys = groupByKeys
|
|
606
603
|
.map((k) => (k !== null && k !== void 0 ? k : "").trim())
|
|
607
604
|
.filter((k) => k)
|
|
@@ -654,6 +651,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
654
651
|
});
|
|
655
652
|
return groupedResult;
|
|
656
653
|
};
|
|
654
|
+
console.log({ parsedKeys });
|
|
657
655
|
return groupData(data, parsedKeys);
|
|
658
656
|
};
|
|
659
657
|
const flattenGroupedData = (groupedData, level, groupedValues = [], parentKeys = []) => {
|
|
@@ -662,7 +660,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
662
660
|
groupedData.forEach((group) => {
|
|
663
661
|
const _groupedValues = [...groupedValues, group.value].map((item) => item ? item : "row");
|
|
664
662
|
const currentKeys = (group.allKeys
|
|
665
|
-
? [...parentKeys, group.allKeys.join("
|
|
663
|
+
? [...parentKeys, group.allKeys.join(">")]
|
|
666
664
|
: [...parentKeys, group.key]).filter((item) => item);
|
|
667
665
|
const groupedValue = _groupedValues.join(">");
|
|
668
666
|
const groupedColumns = currentKeys.join(">");
|
|
@@ -53,10 +53,44 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
|
|
|
53
53
|
height: "max-content",
|
|
54
54
|
boxSizing: "border-box", // Include padding and borders in the element's total width and height
|
|
55
55
|
backgroundColor: "var(--summary-bg)",
|
|
56
|
-
},
|
|
56
|
+
}, children: [(_a = item.groupedKey) === null || _a === void 0 ? void 0 : _a.split(">").flatMap((item) => item.split("+")).map((columnKey, index) => {
|
|
57
|
+
var _a;
|
|
57
58
|
const column = gridColumns.find((column) => column.key === columnKey);
|
|
59
|
+
const keys = (item.groupedKey || "").split(">");
|
|
60
|
+
const vals = (item.groupedValue || "").split(">");
|
|
61
|
+
const idx = keys.indexOf(columnKey);
|
|
62
|
+
const compositeKeys = (item.groupedKey || "")
|
|
63
|
+
.split(">")
|
|
64
|
+
.filter((item) => item.includes("+"))
|
|
65
|
+
.flatMap((item) => item.split("+"));
|
|
66
|
+
const compositeValues = (item.groupedValue || "")
|
|
67
|
+
.split(">")
|
|
68
|
+
.filter((item) => item.includes("+"))
|
|
69
|
+
.flatMap((item) => item.split("+"));
|
|
70
|
+
const compositeIndex = compositeKeys.indexOf(columnKey);
|
|
71
|
+
const intermediate = idx > -1
|
|
72
|
+
? vals[idx]
|
|
73
|
+
: compositeIndex > -1
|
|
74
|
+
? compositeValues[compositeIndex]
|
|
75
|
+
: "";
|
|
76
|
+
let display = "";
|
|
77
|
+
if (intermediate && idx === keys.length - 1) {
|
|
78
|
+
display = `${intermediate} (${item === null || item === void 0 ? void 0 : item.count})`;
|
|
79
|
+
}
|
|
80
|
+
else if (intermediate &&
|
|
81
|
+
compositeIndex === compositeKeys.length - 1 &&
|
|
82
|
+
index ===
|
|
83
|
+
((_a = item.groupedKey) === null || _a === void 0 ? void 0 : _a.split(">").flatMap((item) => item.split("+")).length) -
|
|
84
|
+
1) {
|
|
85
|
+
display = `${intermediate} (${item === null || item === void 0 ? void 0 : item.count})`;
|
|
86
|
+
}
|
|
87
|
+
if (compositeKeys.includes(item.key) ||
|
|
88
|
+
item.key === columnKey) {
|
|
89
|
+
display = intermediate;
|
|
90
|
+
}
|
|
91
|
+
console.log({ display });
|
|
58
92
|
if (column) {
|
|
59
|
-
return (
|
|
93
|
+
return (_jsx("div", { style: {
|
|
60
94
|
width: widthMode === "auto"
|
|
61
95
|
? "auto"
|
|
62
96
|
: (column === null || column === void 0 ? void 0 : column.width)
|
|
@@ -67,58 +101,27 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
|
|
|
67
101
|
flex: widthMode === "auto" ? 1 : undefined,
|
|
68
102
|
flexGrow: widthMode === "auto" ? 1 : 0,
|
|
69
103
|
flexShrink: widthMode === "auto" ? 1 : 0,
|
|
70
|
-
display: "flex",
|
|
71
|
-
alignItems: "center",
|
|
72
104
|
padding: "0.5rem",
|
|
73
|
-
}, className: `column index-${columnKey}`, children:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const compositeKeys = (item.groupedKey || "")
|
|
94
|
-
.split(">")
|
|
95
|
-
.filter((item) => item.includes("+"))
|
|
96
|
-
.flatMap((item) => item.split("+"));
|
|
97
|
-
const compositeValues = (item.groupedValue || "")
|
|
98
|
-
.split(">")
|
|
99
|
-
.filter((item) => item.includes("+"))
|
|
100
|
-
.flatMap((item) => item.split("+"));
|
|
101
|
-
const compositeIndex = compositeKeys.indexOf(columnKey);
|
|
102
|
-
const display = idx > -1
|
|
103
|
-
? vals[idx]
|
|
104
|
-
: compositeIndex > -1
|
|
105
|
-
? compositeValues[compositeIndex]
|
|
106
|
-
: "";
|
|
107
|
-
if (display && idx === keys.length - 1) {
|
|
108
|
-
return `${display} (${item === null || item === void 0 ? void 0 : item.count})`;
|
|
109
|
-
}
|
|
110
|
-
else if (display &&
|
|
111
|
-
compositeIndex === compositeKeys.length - 1 &&
|
|
112
|
-
index ===
|
|
113
|
-
((_a = item.groupedKey) === null || _a === void 0 ? void 0 : _a.split(">").flatMap((item) => item.split("+")).length) -
|
|
114
|
-
1) {
|
|
115
|
-
return `${display} (${item === null || item === void 0 ? void 0 : item.count})`;
|
|
116
|
-
}
|
|
117
|
-
if (compositeKeys.includes(item.key) ||
|
|
118
|
-
item.key === columnKey) {
|
|
119
|
-
return display;
|
|
120
|
-
}
|
|
121
|
-
})() })] }));
|
|
105
|
+
}, className: `column index-${columnKey}`, children: display && (_jsxs("div", { style: {
|
|
106
|
+
display: "flex",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
}, onClick: () => updateRowOpened(item.groupedValue), children: [compositeKeys.includes(item.key) &&
|
|
109
|
+
item.key === columnKey && (_jsx("span", { style: {
|
|
110
|
+
fontSize: "inherit",
|
|
111
|
+
marginRight: "0.5rem",
|
|
112
|
+
color: "var(--foreground)",
|
|
113
|
+
background: "var(--disabled-bg)",
|
|
114
|
+
width: "1rem",
|
|
115
|
+
height: "1rem",
|
|
116
|
+
flexGrow: 0,
|
|
117
|
+
flexShrink: 0,
|
|
118
|
+
borderRadius: 4,
|
|
119
|
+
display: "flex",
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
justifyContent: "center",
|
|
122
|
+
}, children: rowOpened.includes(item.groupedValue || "")
|
|
123
|
+
? "-"
|
|
124
|
+
: "+" })), display] })) }));
|
|
122
125
|
}
|
|
123
126
|
return null;
|
|
124
127
|
}), isSummarise &&
|
package/package.json
CHANGED