@megha-ui/react 1.2.265 → 1.2.267

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
- .map((s) => s
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);
@@ -43,7 +43,7 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
43
43
  .join(">"));
44
44
  })
45
45
  .map((item, gIndex) => {
46
- var _a, _b, _c, _d, _e, _f, _g, _h;
46
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
47
47
  if (gIndex >= startIndex && gIndex <= endIndex)
48
48
  return item.type === "main" ? (_jsxs("div", { style: {
49
49
  width: "100%",
@@ -53,10 +53,7 @@ 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
- }, children: [(item.groupedColumns || "")
57
- .split(">")
58
- .filter((key) => key && key !== item.key)
59
- .map((columnKey) => {
56
+ }, children: [(_a = item.groupedKey) === null || _a === void 0 ? void 0 : _a.split(">").filter((key) => key !== item.key).map((columnKey) => {
60
57
  const column = gridColumns.find((column) => column.key === columnKey);
61
58
  if (column) {
62
59
  return (_jsx("div", { style: {
@@ -81,8 +78,8 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
81
78
  fontSize: "inherit",
82
79
  width: widthMode === "auto"
83
80
  ? "auto"
84
- : ((_a = gridColumns.find((column) => column.key === item.key)) === null || _a === void 0 ? void 0 : _a.width)
85
- ? `calc(${(_b = gridColumns.find((column) => column.key === item.key)) === null || _b === void 0 ? void 0 : _b.width} + 25px)`
81
+ : ((_b = gridColumns.find((column) => column.key === item.key)) === null || _b === void 0 ? void 0 : _b.width)
82
+ ? `calc(${(_c = gridColumns.find((column) => column.key === item.key)) === null || _c === void 0 ? void 0 : _c.width} + 25px)`
86
83
  : columnWidths[`column-${item.key}`]
87
84
  ? `calc(${columnWidths[`column-${item.key}`]} + 25px)`
88
85
  : "fit-content",
@@ -109,10 +106,8 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
109
106
  alignItems: "center",
110
107
  flexWrap: "wrap",
111
108
  }, children: [_jsx("span", { style: { marginRight: "0.5rem" }, children: item.html ? _jsx(_Fragment, { children: item.html }) : item.value }), _jsx("span", { children: `(${item === null || item === void 0 ? void 0 : item.count})` })] })] }), isSummarise &&
112
- parseInt(((_c = item === null || item === void 0 ? void 0 : item.count) === null || _c === void 0 ? void 0 : _c.toString()) || "0") > 0 && (_jsx(SummariseDetails, { rowIndex: gIndex, removedKeys: (item.groupedColumns || "")
113
- .split(">")
114
- .filter((key) => key), columns: gridColumns, groupBy: gridGroupBy, sortable: sortable, cellStyle: cellStyle, columnWidths: columnWidths, widthMode: widthMode, summariseKeys: summariseKeys, summariseDetails: summariseDetails, activeCalculateColor: activeCalculateColor, gridRef: gridRef, setCalculatePosition: setCalculatePosition, calculatePosition: calculatePosition, calculatetextColor: calculatetextColor, setCalculateVisible: setCalculateVisible, calculateVisible: calculateVisible, summariseDisplay: summariseDisplay, recalculate: recalculate, groupedData: item.groupedValue, actionsKey: actionsKey }))] }, String((_d = item.groupedValue) !== null && _d !== void 0 ? _d : gIndex))) : (_jsx(GroupedRow, { item: item.rowData, index: gIndex, rowStyle: Object.assign(Object.assign({}, rowStyle), (selectedRow === gIndex ? selectedRowStyle : {})), cellStyle: cellStyle, rowHeight: rowHeight, alternateRowColor: alternateRowColor, bulkSelect: bulkSelect, columns: gridColumns, widthMode: widthMode, rowKey: rowKey, onRowClick: onRowClick, loading: isLoading, groupBy: gridGroupBy, selectedRows: selectedRows, toggleRowSelection: toggleRowSelection, hasVerticalScroll: hasVerticalScroll, hugColumnWidths: columnWidths }, String(((_f = (_e = item.rowData) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.value)
115
- ? `${item.groupedValue}-${(_h = (_g = item.rowData) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.value}`
109
+ parseInt(((_d = item === null || item === void 0 ? void 0 : item.count) === null || _d === void 0 ? void 0 : _d.toString()) || "0") > 0 && (_jsx(SummariseDetails, { rowIndex: gIndex, removedKeys: item.groupedKey.split(">"), columns: gridColumns, groupBy: gridGroupBy, sortable: sortable, cellStyle: cellStyle, columnWidths: columnWidths, widthMode: widthMode, summariseKeys: summariseKeys, summariseDetails: summariseDetails, activeCalculateColor: activeCalculateColor, gridRef: gridRef, setCalculatePosition: setCalculatePosition, calculatePosition: calculatePosition, calculatetextColor: calculatetextColor, setCalculateVisible: setCalculateVisible, calculateVisible: calculateVisible, summariseDisplay: summariseDisplay, recalculate: recalculate, groupedData: item.groupedValue, actionsKey: actionsKey }))] }, String((_e = item.groupedValue) !== null && _e !== void 0 ? _e : gIndex))) : (_jsx(GroupedRow, { item: item.rowData, index: gIndex, rowStyle: Object.assign(Object.assign({}, rowStyle), (selectedRow === gIndex ? selectedRowStyle : {})), cellStyle: cellStyle, rowHeight: rowHeight, alternateRowColor: alternateRowColor, bulkSelect: bulkSelect, columns: gridColumns, widthMode: widthMode, rowKey: rowKey, onRowClick: onRowClick, loading: isLoading, groupBy: gridGroupBy, selectedRows: selectedRows, toggleRowSelection: toggleRowSelection, hasVerticalScroll: hasVerticalScroll, hugColumnWidths: columnWidths }, String(((_g = (_f = item.rowData) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.value)
110
+ ? `${item.groupedValue}-${(_j = (_h = item.rowData) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.value}`
116
111
  : gIndex)));
117
112
  }) }));
118
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.265",
3
+ "version": "1.2.267",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",