@megha-ui/react 1.2.336 → 1.2.337

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,43 @@ 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
- }, onClick: () => updateRowOpened(item.groupedValue), children: [(_a = item.groupedKey) === null || _a === void 0 ? void 0 : _a.split(">").flatMap((item) => item.split("+")).map((columnKey, index) => {
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
+ }
58
91
  if (column) {
59
- return (_jsxs("div", { style: {
92
+ return (_jsx("div", { style: {
60
93
  width: widthMode === "auto"
61
94
  ? "auto"
62
95
  : (column === null || column === void 0 ? void 0 : column.width)
@@ -67,58 +100,27 @@ const GroupedGrid = ({ groupedData, rowOpened, startIndex, endIndex, alternateRo
67
100
  flex: widthMode === "auto" ? 1 : undefined,
68
101
  flexGrow: widthMode === "auto" ? 1 : 0,
69
102
  flexShrink: widthMode === "auto" ? 1 : 0,
70
- display: "flex",
71
- alignItems: "center",
72
103
  padding: "0.5rem",
73
- }, className: `column index-${columnKey}`, children: [index === 0 && (_jsx("span", { style: {
74
- fontSize: "inherit",
75
- marginRight: "0.5rem",
76
- color: "var(--foreground)",
77
- background: "var(--disabled-bg)",
78
- width: "1rem",
79
- height: "1rem",
80
- flexGrow: 0,
81
- flexShrink: 0,
82
- borderRadius: 4,
83
- display: "flex",
84
- alignItems: "center",
85
- justifyContent: "center",
86
- }, children: rowOpened.includes(item.groupedValue || "")
87
- ? "-"
88
- : "+" })), _jsx("div", { children: (() => {
89
- var _a;
90
- const keys = (item.groupedKey || "").split(">");
91
- const vals = (item.groupedValue || "").split(">");
92
- const idx = keys.indexOf(columnKey);
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
- })() })] }));
104
+ }, className: `column index-${columnKey}`, children: display && (_jsxs("div", { style: {
105
+ display: "flex",
106
+ alignItems: "center",
107
+ }, onClick: () => updateRowOpened(item.groupedValue), children: [compositeKeys.includes(item.key) &&
108
+ item.key === columnKey && (_jsx("span", { style: {
109
+ fontSize: "inherit",
110
+ marginRight: "0.5rem",
111
+ color: "var(--foreground)",
112
+ background: "var(--disabled-bg)",
113
+ width: "1rem",
114
+ height: "1rem",
115
+ flexGrow: 0,
116
+ flexShrink: 0,
117
+ borderRadius: 4,
118
+ display: "flex",
119
+ alignItems: "center",
120
+ justifyContent: "center",
121
+ }, children: rowOpened.includes(item.groupedValue || "")
122
+ ? "-"
123
+ : "+" })), display] })) }));
122
124
  }
123
125
  return null;
124
126
  }), isSummarise &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.336",
3
+ "version": "1.2.337",
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",