@megha-ui/react 1.2.757 → 1.2.759
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.
|
@@ -1503,7 +1503,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
1503
1503
|
whiteSpace: "nowrap",
|
|
1504
1504
|
height: `calc(100% - ${removalHeight})`,
|
|
1505
1505
|
position: "relative",
|
|
1506
|
-
}, onScroll: onScroll, ref: gridRef, children: [_jsx(GridHeader, { columns: gridColumns, headerRef: headerRef, resizable: resizable, sortable: sortable, search: search, defaultSearchOperation: defaultSearchOperation, showMenu: showMenu, sortQueries: sortQueries, onSort: handleSort, bulkSelect: bulkSelect, cellStyle: cellStyle, widthMode: widthMode, allRowsSelected: allRowsSelected, someRowsSelected: someRowsSelected, toggleSelectAll: () => toggleSelectAll(paginate ? paginatedData : sortedData, allRowsSelected), onSearch: handleSearch, searchQueries: searchQueries, headerBackground: headerBackground, headerTopBorder: headerTopBorder, headerBottomBorder: headerBottomBorder, groupBy: gridGroupBy, setGroupBy: (value) => {
|
|
1506
|
+
}, onScroll: onScroll, ref: gridRef, children: [_jsx(GridHeader, { columns: gridColumns, headerRef: headerRef, resizable: resizable, sortable: sortable, search: search, combinedColumns: combinedColumns, defaultSearchOperation: defaultSearchOperation, showMenu: showMenu, sortQueries: sortQueries, onSort: handleSort, bulkSelect: bulkSelect, cellStyle: cellStyle, widthMode: widthMode, allRowsSelected: allRowsSelected, someRowsSelected: someRowsSelected, toggleSelectAll: () => toggleSelectAll(paginate ? paginatedData : sortedData, allRowsSelected), onSearch: handleSearch, searchQueries: searchQueries, headerBackground: headerBackground, headerTopBorder: headerTopBorder, headerBottomBorder: headerBottomBorder, groupBy: gridGroupBy, setGroupBy: (value) => {
|
|
1507
1507
|
let _gridGroupBy = gridGroupBy;
|
|
1508
1508
|
_gridGroupBy = _gridGroupBy.split(",").includes(value)
|
|
1509
1509
|
? _gridGroupBy
|
|
@@ -54,7 +54,20 @@ interface GridHeaderProps {
|
|
|
54
54
|
columnSearchOutside: boolean;
|
|
55
55
|
locale?: string;
|
|
56
56
|
formatOptions?: any;
|
|
57
|
+
combinedColumns?: {
|
|
58
|
+
name: string;
|
|
59
|
+
key: string;
|
|
60
|
+
separator: string;
|
|
61
|
+
columns: string[];
|
|
62
|
+
sortOn: string[];
|
|
63
|
+
}[];
|
|
57
64
|
}
|
|
58
|
-
export declare const getColumnData: (columnKey: string, gridData: DataRow[], type: string
|
|
65
|
+
export declare const getColumnData: (columnKey: string, gridData: DataRow[], type: string, combinedColumns: {
|
|
66
|
+
name: string;
|
|
67
|
+
key: string;
|
|
68
|
+
separator: string;
|
|
69
|
+
columns: string[];
|
|
70
|
+
sortOn: string[];
|
|
71
|
+
}[]) => (string | number)[];
|
|
59
72
|
declare const _default: React.NamedExoticComponent<GridHeaderProps>;
|
|
60
73
|
export default _default;
|
|
@@ -8,7 +8,7 @@ import DateInput from "../../date-input";
|
|
|
8
8
|
import TextInput from "../../text-input";
|
|
9
9
|
import Checkbox from "../../checkbox";
|
|
10
10
|
import { Tooltip } from "react-tooltip";
|
|
11
|
-
export const getColumnData = (columnKey, gridData, type) => {
|
|
11
|
+
export const getColumnData = (columnKey, gridData, type, combinedColumns) => {
|
|
12
12
|
const returnedValue = [
|
|
13
13
|
...new Set(gridData
|
|
14
14
|
.filter((item) => item[columnKey] && typeof item[columnKey].value !== "undefined")
|
|
@@ -21,20 +21,46 @@ export const getColumnData = (columnKey, gridData, type) => {
|
|
|
21
21
|
: data[columnKey].value)),
|
|
22
22
|
];
|
|
23
23
|
return returnedValue.sort((a, b) => {
|
|
24
|
-
|
|
24
|
+
let aValue = a
|
|
25
25
|
? type === "number" || type === "currency"
|
|
26
26
|
? parseFloat(a === null || a === void 0 ? void 0 : a.toString())
|
|
27
27
|
: a === null || a === void 0 ? void 0 : a.toString().toUpperCase()
|
|
28
28
|
: type === "number" || type === "currency"
|
|
29
29
|
? 0
|
|
30
30
|
: "";
|
|
31
|
-
|
|
31
|
+
let bValue = b
|
|
32
32
|
? type === "number" || type === "currency"
|
|
33
33
|
? parseFloat(b === null || b === void 0 ? void 0 : b.toString())
|
|
34
34
|
: b === null || b === void 0 ? void 0 : b.toString().toUpperCase()
|
|
35
35
|
: type === "number" || type === "currency"
|
|
36
36
|
? 0
|
|
37
37
|
: "";
|
|
38
|
+
if (combinedColumns && (combinedColumns === null || combinedColumns === void 0 ? void 0 : combinedColumns.length) > 0) {
|
|
39
|
+
const combinedColumn = combinedColumns.find((col) => col.key === columnKey);
|
|
40
|
+
if (combinedColumn) {
|
|
41
|
+
const { columns: combinedCols, separator, sortOn } = combinedColumn;
|
|
42
|
+
if (sortOn) {
|
|
43
|
+
const index = combinedCols.findIndex((colKey) => colKey === sortOn[0]);
|
|
44
|
+
const aVals = ((aValue === null || aValue === void 0 ? void 0 : aValue.toString()) || "").split(separator);
|
|
45
|
+
const bVals = ((bValue === null || bValue === void 0 ? void 0 : bValue.toString()) || "").split(separator);
|
|
46
|
+
aValue = aVals[index] || "";
|
|
47
|
+
bValue = bVals[index] || "";
|
|
48
|
+
if (parseFloat(aValue).toString() !== "NaN" &&
|
|
49
|
+
parseFloat(bValue).toString() !== "NaN") {
|
|
50
|
+
aValue = parseFloat(aValue);
|
|
51
|
+
bValue = parseFloat(bValue);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (columnKey !== "id" &&
|
|
57
|
+
aValue.toString().includes("-") &&
|
|
58
|
+
bValue.toString().includes("-")) {
|
|
59
|
+
aValue = aValue.toString().split("-")[0];
|
|
60
|
+
bValue = bValue.toString().split("-")[0];
|
|
61
|
+
aValue = isNaN(parseFloat(aValue)) ? aValue : parseFloat(aValue);
|
|
62
|
+
bValue = isNaN(parseFloat(bValue)) ? bValue : parseFloat(bValue);
|
|
63
|
+
}
|
|
38
64
|
if (aValue < bValue)
|
|
39
65
|
return -1;
|
|
40
66
|
if (aValue > bValue)
|
|
@@ -42,7 +68,7 @@ export const getColumnData = (columnKey, gridData, type) => {
|
|
|
42
68
|
return 0;
|
|
43
69
|
});
|
|
44
70
|
};
|
|
45
|
-
const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resizable = false, defaultSearchOperation, sortQueries, onSort, bulkSelect, allRowsSelected, someRowsSelected, toggleSelectAll, cellStyle, widthMode, rowHeight, headerRef, showMenu, headerBackground, headerTopBorder, headerBottomBorder, groupBy, setGroupBy, updateGridColumns, setGridColumns, headerDropdownIndex, widthUnits, textFilterLabel = "Text Filter", gridData, checkboxWrapper, onFilter, setUniqueSearch, uniqueSearch, hugColumnWidths, menuVisible, setMenuVisible, dropdownVisible, setDropdownVisible, actionsKey = "actions", columnSearchOutside, locale, formatOptions, }) => {
|
|
71
|
+
const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resizable = false, defaultSearchOperation, sortQueries, onSort, bulkSelect, allRowsSelected, someRowsSelected, toggleSelectAll, cellStyle, widthMode, rowHeight, headerRef, showMenu, headerBackground, headerTopBorder, headerBottomBorder, groupBy, setGroupBy, updateGridColumns, setGridColumns, headerDropdownIndex, widthUnits, textFilterLabel = "Text Filter", gridData, checkboxWrapper, onFilter, setUniqueSearch, uniqueSearch, hugColumnWidths, menuVisible, setMenuVisible, dropdownVisible, setDropdownVisible, actionsKey = "actions", columnSearchOutside, locale, formatOptions, combinedColumns }) => {
|
|
46
72
|
const [menuPosition, setMenuPosition] = useState(null);
|
|
47
73
|
const [searchOpsPosition, setSearchOpsPosition] = useState(null);
|
|
48
74
|
const [headerColumns, setHeaderColumns] = useState([]);
|
|
@@ -329,7 +355,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
|
|
|
329
355
|
: ((_b = headerColumns.find((column) => column.key === _groupBy)) === null || _b === void 0 ? void 0 : _b.dataType) === "date"
|
|
330
356
|
? dateTypeSearch.includes(item.value)
|
|
331
357
|
: textTypeSearch.includes(item.value);
|
|
332
|
-
}), position: searchOpsPosition || { top: 0, left: 0 }, columnKey: ((_3 = headerColumns.find((column) => column.key === _groupBy)) === null || _3 === void 0 ? void 0 : _3.key) || "", columnData: getColumnData(((_4 = headerColumns.find((column) => column.key === _groupBy)) === null || _4 === void 0 ? void 0 : _4.key) || "", gridData, (_6 = (_5 = headerColumns.find((column) => column.key === _groupBy)) === null || _5 === void 0 ? void 0 : _5.dataType) !== null && _6 !== void 0 ? _6 : "string"), searchElement: _jsx("div", { id: "search-input", children: ((_7 = headerColumns.find((column) => column.key === _groupBy)) === null || _7 === void 0 ? void 0 : _7.dataType) === "date" ? (((_9 = searchQueries[((_8 = headerColumns.find((column) => column.key === _groupBy)) === null || _8 === void 0 ? void 0 : _8.key) || ""]) === null || _9 === void 0 ? void 0 : _9.type) === "between" ? (_jsxs(_Fragment, { children: [_jsx(DateInput, { value: (_11 = searchQueries[((_10 = headerColumns.find((column) => column.key === _groupBy)) === null || _10 === void 0 ? void 0 : _10.key) || ""]) === null || _11 === void 0 ? void 0 : _11.text.split("to")[0], placeholder: `From date`, onChange: (value) => {
|
|
358
|
+
}), position: searchOpsPosition || { top: 0, left: 0 }, columnKey: ((_3 = headerColumns.find((column) => column.key === _groupBy)) === null || _3 === void 0 ? void 0 : _3.key) || "", columnData: getColumnData(((_4 = headerColumns.find((column) => column.key === _groupBy)) === null || _4 === void 0 ? void 0 : _4.key) || "", gridData, (_6 = (_5 = headerColumns.find((column) => column.key === _groupBy)) === null || _5 === void 0 ? void 0 : _5.dataType) !== null && _6 !== void 0 ? _6 : "string", combinedColumns !== null && combinedColumns !== void 0 ? combinedColumns : []), searchElement: _jsx("div", { id: "search-input", children: ((_7 = headerColumns.find((column) => column.key === _groupBy)) === null || _7 === void 0 ? void 0 : _7.dataType) === "date" ? (((_9 = searchQueries[((_8 = headerColumns.find((column) => column.key === _groupBy)) === null || _8 === void 0 ? void 0 : _8.key) || ""]) === null || _9 === void 0 ? void 0 : _9.type) === "between" ? (_jsxs(_Fragment, { children: [_jsx(DateInput, { value: (_11 = searchQueries[((_10 = headerColumns.find((column) => column.key === _groupBy)) === null || _10 === void 0 ? void 0 : _10.key) || ""]) === null || _11 === void 0 ? void 0 : _11.text.split("to")[0], placeholder: `From date`, onChange: (value) => {
|
|
333
359
|
var _a, _b, _c, _d, _e;
|
|
334
360
|
return onSearch(((_a = headerColumns.find((column) => column.key === _groupBy)) === null || _a === void 0 ? void 0 : _a.key) || "", (_c = searchQueries[((_b = headerColumns.find((column) => column.key === _groupBy)) === null || _b === void 0 ? void 0 : _b.key) || ""]) === null || _c === void 0 ? void 0 : _c.text.split("to").map((item, index) => {
|
|
335
361
|
if (index === 0) {
|
|
@@ -511,7 +537,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
|
|
|
511
537
|
.map((column, colIndex) => {
|
|
512
538
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
513
539
|
if (!column.hidden) {
|
|
514
|
-
const columnData = getColumnData(column.key, gridData, (_a = column.dataType) !== null && _a !== void 0 ? _a : "string");
|
|
540
|
+
const columnData = getColumnData(column.key, gridData, (_a = column.dataType) !== null && _a !== void 0 ? _a : "string", combinedColumns !== null && combinedColumns !== void 0 ? combinedColumns : []);
|
|
515
541
|
return (_jsx("div", { className: `${sortable && column.sortable ? "sortable" : ""} ${column.showMenu ? "menu-true" : "menu-false"} column index-${column.key}`, style: Object.assign(Object.assign({}, cellStyle), { position: "relative", padding: "0.5rem", textAlign: "left", whiteSpace: "nowrap", textOverflow: "ellipsis", width: widthMode === "auto"
|
|
516
542
|
? "auto"
|
|
517
543
|
: column.width
|
package/package.json
CHANGED