@megha-ui/react 1.2.239 → 1.2.241

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.
@@ -1,6 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
2
3
  import CalculateDropdown from "./calculatedropdown";
3
4
  const SummariseDetails = ({ columns, rowIndex, groupBy, sortable, cellStyle, columnWidths, widthMode, summariseDetails, summariseKeys, activeCalculateColor, gridRef, setCalculatePosition, calculatePosition, calculatetextColor = "#aaa", setCalculateVisible, calculateVisible, summariseDisplay, recalculate, groupedData, removedKeys = [], actionsKey, }) => {
5
+ const groupByKeys = React.useMemo(() => (groupBy || "")
6
+ .split(",")
7
+ .filter((g) => g)
8
+ .flatMap((g) => g.split("+").filter((k) => k)), [groupBy]);
4
9
  const handleCalculateSelect = (_columnKey, type) => {
5
10
  let columnKey = _columnKey;
6
11
  if (columnKey.includes("-")) {
@@ -161,7 +166,7 @@ const SummariseDetails = ({ columns, rowIndex, groupBy, sortable, cellStyle, col
161
166
  ? dateTypeCalcOps.includes(item.value)
162
167
  : textTypeCalcOps.includes(item.value)), onClose: () => setCalculateVisible(""), columnKey: columnKey || "" }))] }, `${groupedData}-${_groupBy}`));
163
168
  }), columns
164
- .filter((column) => !groupBy.includes(column.key))
169
+ .filter((column) => !groupByKeys.includes(column.key))
165
170
  .map((column) => {
166
171
  var _a;
167
172
  const columnKey = groupedData
@@ -46,6 +46,11 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
46
46
  const [searchOpsPosition, setSearchOpsPosition] = useState(null);
47
47
  const [headerColumns, setHeaderColumns] = useState([]);
48
48
  const [resizeIndex, setResizeIndex] = useState(-1);
49
+ // Support composite groupBy (e.g., "colA+colB,colC") by flattening to keys
50
+ const groupByKeys = useMemo(() => (groupBy || "")
51
+ .split(",")
52
+ .filter((g) => g)
53
+ .flatMap((g) => g.split("+").filter((k) => k)), [groupBy]);
49
54
  const handleMenuClick = (e, columnKey) => {
50
55
  e.stopPropagation();
51
56
  const rect = e.currentTarget.getBoundingClientRect();
@@ -230,10 +235,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
230
235
  position: "sticky",
231
236
  top: 0,
232
237
  zIndex: 1,
233
- }, id: "header", children: [bulkSelect && (_jsx("div", { style: Object.assign(Object.assign({}, cellStyle), { textTransform: "uppercase", padding: "0.5rem", textAlign: "left", whiteSpace: "nowrap", textOverflow: "ellipsis" }), children: _jsx(Checkbox, { selected: allRowsSelected, onChange: () => toggleSelectAll(), noLabel: true, wrapperClass: checkboxWrapper }) })), groupBy
234
- .split(",")
235
- .filter((item) => item)
236
- .map((_groupBy) => {
238
+ }, id: "header", children: [bulkSelect && (_jsx("div", { style: Object.assign(Object.assign({}, cellStyle), { textTransform: "uppercase", padding: "0.5rem", textAlign: "left", whiteSpace: "nowrap", textOverflow: "ellipsis" }), children: _jsx(Checkbox, { selected: allRowsSelected, onChange: () => toggleSelectAll(), noLabel: true, wrapperClass: checkboxWrapper }) })), groupByKeys.map((_groupBy) => {
237
239
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62;
238
240
  return (_jsx(_Fragment, { children: headerColumns.find((column) => column.key === _groupBy) && (_jsxs("div", { className: `${sortable &&
239
241
  ((_a = headerColumns.find((column) => column.key === _groupBy)) === null || _a === void 0 ? void 0 : _a.sortable)
@@ -507,7 +509,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
507
509
  : "var(--disabled-bg)",
508
510
  }, height: 32, extraInputStyle: { minWidth: 10 }, className: "w-full", backgroundColor: "var(--background)" }) }))] }, (_62 = headerColumns.find((column) => column.key === _groupBy)) === null || _62 === void 0 ? void 0 : _62.key)) }));
509
511
  }), headerColumns
510
- .filter((column) => !groupBy.includes(column.key))
512
+ .filter((column) => !groupByKeys.includes(column.key))
511
513
  .map((column, colIndex) => {
512
514
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
513
515
  if (!column.hidden) {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo, useCallback, useEffect, useState } from "react";
2
+ import { memo, useCallback, useEffect, useMemo, useState } from "react";
3
3
  import Shimmer from "./shimmer";
4
4
  import Checkbox from "../../checkbox";
5
5
  import { formatValue } from "../../../services/commonService";
@@ -22,6 +22,10 @@ const GridRow = ({ item, rowStyle, cellStyle, rowHeight, bulkSelect, selectedRow
22
22
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
23
23
  const [itemsAlign, setItemsAlign] = useState("stretch");
24
24
  const [draggableIndex, setDraggableIndex] = useState(0);
25
+ const groupByKeys = useMemo(() => (groupBy || "")
26
+ .split(",")
27
+ .filter((g) => g)
28
+ .flatMap((g) => g.split("+").filter((k) => k)), [groupBy]);
25
29
  const handleRowClick = useCallback(() => {
26
30
  onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(item);
27
31
  }, [onRowClick, item]);
@@ -77,7 +81,7 @@ const GridRow = ({ item, rowStyle, cellStyle, rowHeight, bulkSelect, selectedRow
77
81
  : "";
78
82
  const cellUrl = cellData === null || cellData === void 0 ? void 0 : cellData.url;
79
83
  const isHidden = column.overflowHidden;
80
- if (!column.hidden && groupBy !== column.key) {
84
+ if (!column.hidden && !groupByKeys.includes(column.key)) {
81
85
  return (_jsxs("div", { id: `column-${index}-${colIndex}`, className: `column index-${column.key}`, style: Object.assign(Object.assign({}, cellStyle), { padding: "0.5rem", display: "flex", alignItems: "center", justifyContent: "flex-start", overflow: isHidden ? "hidden" : "visible", textOverflow: isHidden ? "ellipsis" : "clip", whiteSpace: isHidden ? "nowrap" : "normal", width: widthMode === "auto"
82
86
  ? "auto"
83
87
  : (column === null || column === void 0 ? void 0 : column.width)
@@ -127,7 +131,7 @@ const GridRow = ({ item, rowStyle, cellStyle, rowHeight, bulkSelect, selectedRow
127
131
  : "";
128
132
  const cellUrl = cellData === null || cellData === void 0 ? void 0 : cellData.url;
129
133
  const isHidden = column.overflowHidden;
130
- if (!column.hidden && groupBy !== column.key) {
134
+ if (!column.hidden && !groupByKeys.includes(column.key)) {
131
135
  return (_jsxs("div", { id: `column-${index}-${colIndex}`, className: `column index-${column.key}`, style: Object.assign(Object.assign({}, cellStyle), { padding: "0.5rem", display: "flex", alignItems: "center", justifyContent: "flex-start", overflow: isHidden ? "hidden" : "visible", textOverflow: isHidden ? "ellipsis" : "clip", whiteSpace: isHidden ? "nowrap" : "normal", width: widthMode === "auto"
132
136
  ? "auto"
133
137
  : (column === null || column === void 0 ? void 0 : column.width)
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo, useCallback } from "react";
2
+ import { memo, useCallback, useMemo } from "react";
3
3
  import Shimmer from "./shimmer";
4
4
  const isUrl = (value) => {
5
5
  if (value) {
@@ -25,12 +25,13 @@ const GroupedRow = ({ item, rowStyle, cellStyle, rowHeight, columns, widthMode,
25
25
  classNames.push("cursor-pointer");
26
26
  return classNames.join(" ");
27
27
  }, [onRowClick]);
28
+ const groupByKeys = useMemo(() => (groupBy || "")
29
+ .split(",")
30
+ .filter((g) => g)
31
+ .flatMap((g) => g.split("+").filter((k) => k)), [groupBy]);
28
32
  return (_jsxs("div", { id: `${index}`, className: getRowClassNames(), style: Object.assign(Object.assign({}, rowStyle), { position: "relative", display: "flex", alignItems: "center", fontSize: "inherit", minHeight: rowHeight, height: "max-content", boxSizing: "border-box", backgroundColor: alternateRowColor && (index + 1) % 2 === 0
29
33
  ? "var(--row-bg)"
30
- : "var(--row-bg-even)" }), onClick: handleRowClick, children: [groupBy
31
- .split(",")
32
- .filter((item) => item)
33
- .map((_groupBy) => {
34
+ : "var(--row-bg-even)" }), onClick: handleRowClick, children: [groupByKeys.map((_groupBy) => {
34
35
  var _a, _b;
35
36
  return (_jsx("div", { style: {
36
37
  width: widthMode === "auto"
@@ -47,9 +48,9 @@ const GroupedRow = ({ item, rowStyle, cellStyle, rowHeight, columns, widthMode,
47
48
  flex: widthMode === "auto" ? 1 : undefined,
48
49
  flexGrow: widthMode === "auto" ? 1 : 0,
49
50
  flexShrink: widthMode === "auto" ? 1 : 0,
50
- }, className: `column index-${groupBy}`, children: _jsx("div", {}) }));
51
+ }, className: `column index-${_groupBy}`, children: _jsx("div", {}) }));
51
52
  }), columns
52
- .filter((column) => !groupBy.includes(column.key))
53
+ .filter((column) => !groupByKeys.includes(column.key))
53
54
  .map((column, colIndex) => {
54
55
  var _a, _b;
55
56
  const cellData = item[column.key];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.239",
3
+ "version": "1.2.241",
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",