@megha-ui/react 1.2.169 → 1.2.171
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.
- package/dist/components/block/index.js +3 -5
- package/dist/components/button/index.js +3 -5
- package/dist/components/button/types/borderStyle.js +1 -2
- package/dist/components/button/types/cursorType.js +1 -2
- package/dist/components/card/index.js +7 -9
- package/dist/components/checkbox/index.js +7 -9
- package/dist/components/date-input/index.js +6 -8
- package/dist/components/dropdown/index.js +42 -47
- package/dist/components/grid/hooks/useBulkSelect.js +6 -10
- package/dist/components/grid/hooks/usePagination.js +6 -10
- package/dist/components/grid/hooks/useResizeObserver.js +3 -5
- package/dist/components/grid/hooks/useSearch.js +3 -7
- package/dist/components/grid/hooks/useSort.js +4 -8
- package/dist/components/grid/hooks/useVisibleData.js +6 -10
- package/dist/components/grid/index.js +149 -188
- package/dist/components/grid/types/grid.d.ts +1 -0
- package/dist/components/grid/types/grid.js +1 -2
- package/dist/components/grid/utils/SummariseDetails.js +12 -17
- package/dist/components/grid/utils/calculatedropdown.js +4 -6
- package/dist/components/grid/utils/globalSearchChips.js +11 -16
- package/dist/components/grid/utils/gridFilterDropdown.js +22 -27
- package/dist/components/grid/utils/gridHeader.js +78 -118
- package/dist/components/grid/utils/gridHeaderDropdown.js +4 -6
- package/dist/components/grid/utils/gridRow.js +29 -34
- package/dist/components/grid/utils/groupedGridDetails.js +17 -22
- package/dist/components/grid/utils/groupedRow.js +12 -17
- package/dist/components/grid/utils/pagination.js +7 -11
- package/dist/components/grid/utils/paginationUtils.js +1 -5
- package/dist/components/grid/utils/regexUtils.js +2 -7
- package/dist/components/grid/utils/shimmer.js +4 -6
- package/dist/components/grid/utils/textFilterDropdown.js +8 -13
- package/dist/components/loader/index.js +6 -41
- package/dist/components/modal/index.js +11 -13
- package/dist/components/tabs/index.js +19 -26
- package/dist/components/text/index.js +3 -5
- package/dist/components/text/textType.js +1 -2
- package/dist/components/text-input/index.js +10 -12
- package/dist/components/textarea/index.js +3 -5
- package/dist/components/texteditor/index.js +25 -27
- package/dist/components/toggle/index.js +4 -6
- package/dist/index.js +16 -41
- package/dist/services/commonService.js +3 -7
- package/package.json +1 -1
|
@@ -1,84 +1,46 @@
|
|
|
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
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
|
-
const react_1 = require("react");
|
|
41
|
-
const XLSX = __importStar(require("xlsx"));
|
|
42
|
-
const file_saver_1 = require("file-saver");
|
|
43
|
-
const pagination_1 = __importDefault(require("./utils/pagination"));
|
|
44
|
-
const gridRow_1 = __importDefault(require("./utils/gridRow"));
|
|
45
|
-
const pagination_2 = require("./utils/pagination");
|
|
46
|
-
const gridHeader_1 = __importDefault(require("./utils/gridHeader"));
|
|
47
|
-
const useSort_1 = require("./hooks/useSort");
|
|
48
|
-
const usePagination_1 = require("./hooks/usePagination");
|
|
49
|
-
const useBulkSelect_1 = require("./hooks/useBulkSelect");
|
|
50
|
-
const regexUtils_1 = require("./utils/regexUtils");
|
|
51
|
-
const fi_1 = require("react-icons/fi");
|
|
52
|
-
const md_1 = require("react-icons/md");
|
|
53
|
-
const SummariseDetails_1 = __importDefault(require("./utils/SummariseDetails"));
|
|
54
|
-
const globalSearchChips_1 = __importDefault(require("./utils/globalSearchChips"));
|
|
55
|
-
const groupedGridDetails_1 = __importDefault(require("./utils/groupedGridDetails"));
|
|
56
|
-
const md_2 = require("react-icons/md");
|
|
57
|
-
const dropdown_1 = __importDefault(require("../dropdown"));
|
|
58
|
-
const loader_1 = __importDefault(require("../loader"));
|
|
59
|
-
const button_1 = __importDefault(require("../button"));
|
|
60
|
-
const tb_1 = require("react-icons/tb");
|
|
61
|
-
const commonService_1 = require("../../services/commonService");
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef, useMemo, } from "react";
|
|
3
|
+
import * as XLSX from "xlsx";
|
|
4
|
+
import { saveAs } from "file-saver";
|
|
5
|
+
import Pagination from "./utils/pagination";
|
|
6
|
+
import GridRow from "./utils/gridRow";
|
|
7
|
+
import { getTotalPages } from "./utils/pagination";
|
|
8
|
+
import GridHeader from "./utils/gridHeader";
|
|
9
|
+
import { useSort } from "./hooks/useSort";
|
|
10
|
+
import { usePagination } from "./hooks/usePagination";
|
|
11
|
+
import { useBulkSelect } from "./hooks/useBulkSelect";
|
|
12
|
+
import { createRegexFromWildcard, isValidDateFormat } from "./utils/regexUtils";
|
|
13
|
+
import { FiEye, FiShare, FiChevronsLeft, FiChevronsRight, } from "react-icons/fi";
|
|
14
|
+
import { MdFilterAltOff, MdGroupOff, MdSave } from "react-icons/md";
|
|
15
|
+
import SummariseDetails from "./utils/SummariseDetails";
|
|
16
|
+
import GlobalSearchChiProps from "./utils/globalSearchChips";
|
|
17
|
+
import GroupedGridDetails from "./utils/groupedGridDetails";
|
|
18
|
+
import { MdFullscreen, MdFullscreenExit, } from "react-icons/md";
|
|
19
|
+
import Dropdown from "../dropdown";
|
|
20
|
+
import Loader from "../loader";
|
|
21
|
+
import Button from "../button";
|
|
22
|
+
import { TbAntennaBarsOff, TbCalculator, TbCalculatorFilled, TbCalculatorOff, } from "react-icons/tb";
|
|
23
|
+
import { formatValue } from "../../services/commonService";
|
|
62
24
|
const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable = true, paginate, rowsPerPageOptions = [10, 20, 50, 100], defaultRowsPerPage = 100, widthMode = "custom", bulkSelect = false, cellBorder = false, rowHeight = 38, onRowClick, rowCount = false, rowBorder = true, showMenu = false, search = false, defaultSearchOperation = "contains", gridBorder = false, isLoading = false, rowTopBorder, rowBottomBorder, rowLeftBorder, rowRightBorder, headerBackground = "var(--row-header-bg)", headerTopBorder = "none", headerBottomBorder = "none", SettingIcon, ExportIcon, ignoredExportItems = ["action", "actions"], borderColor = "#dbdfe9", updateColumns, showHideAvailable = false, columnSearchOutside = false, multiSorting = false, exportAvailable = false, exportableFileName = "", groupBy, updateGroupBy, rowKey = "id", hlBorderColor = "black", selectedRow, selectedRowStyle = {
|
|
63
25
|
borderLeft: "0.5rem solid #d9d9d9",
|
|
64
26
|
}, defaultSort, noKeyEvents = true, customOperation, hasCustomOperation, globalSearch, headerDropdownIndex, draggable = false, resizable = false, updateGridData, widthUnits, checkboxWrapper, ignoreHugContent = false, setRendered, isSummarise = true, fullScreenAvailable = true, defaultGroupOpen, alternateRowColor = true, activeCalculateColor = "#2377BA", calculatetextColor = "#fff", actionsKey = "actions", saveAsNewView = false, handleSaveAsView, saveAsViewIcon, filterData, chipColor = "#ccc", withAscii = false, propSummariseKeys, SummariseIcon, summarizeColor = "black", isExpandable = false, expandedRow, extraRow, selectedCheckBox, setSelectedCheckbox, ignoreRowSelect, setOpenedRows, openedRows, getLoadingState, globalSearchOpen = false, updateFixedFilterValues = (fixedFilterValues) => {
|
|
65
27
|
console.log("Update fixed filter values not implemented", fixedFilterValues);
|
|
66
|
-
}, locale, formatOptions, }) => {
|
|
28
|
+
}, locale, formatOptions, exportOptions }) => {
|
|
67
29
|
var _a, _b, _c, _d;
|
|
68
|
-
const [searchQueries, setSearchQueries] =
|
|
69
|
-
const [chips, setChips] =
|
|
70
|
-
const [isOpen, setIsOpen] =
|
|
71
|
-
const [filterColumns, setFilterColumn] =
|
|
72
|
-
const modalContent =
|
|
73
|
-
const [startIndex, setStartIndex] =
|
|
74
|
-
const [endIndex, setEndIndex] =
|
|
75
|
-
const [gridGroupBy, setGridGroupBy] =
|
|
76
|
-
const [rowIndex, setRowIndex] =
|
|
77
|
-
const [columnIndex, setColumnIndex] =
|
|
78
|
-
const [removalHeight, setRemovalHeight] =
|
|
79
|
-
const [gridColumns, setGridColumns] =
|
|
80
|
-
const [uniqueSearch, setUniqueSearch] =
|
|
81
|
-
const [globalInputSearch, setGlobalInputSearch] =
|
|
30
|
+
const [searchQueries, setSearchQueries] = useState({});
|
|
31
|
+
const [chips, setChips] = useState([]);
|
|
32
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
33
|
+
const [filterColumns, setFilterColumn] = useState([]);
|
|
34
|
+
const modalContent = useRef(null);
|
|
35
|
+
const [startIndex, setStartIndex] = useState(0);
|
|
36
|
+
const [endIndex, setEndIndex] = useState(defaultRowsPerPage);
|
|
37
|
+
const [gridGroupBy, setGridGroupBy] = useState("");
|
|
38
|
+
const [rowIndex, setRowIndex] = useState(-1);
|
|
39
|
+
const [columnIndex, setColumnIndex] = useState(-1);
|
|
40
|
+
const [removalHeight, setRemovalHeight] = useState("0px");
|
|
41
|
+
const [gridColumns, setGridColumns] = useState([]);
|
|
42
|
+
const [uniqueSearch, setUniqueSearch] = useState({});
|
|
43
|
+
const [globalInputSearch, setGlobalInputSearch] = useState("");
|
|
82
44
|
const summariseDisplay = {
|
|
83
45
|
count: "Count",
|
|
84
46
|
countUnqValues: "Unique",
|
|
@@ -94,36 +56,36 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
94
56
|
new: "Earliest",
|
|
95
57
|
old: "Latest",
|
|
96
58
|
};
|
|
97
|
-
const [prevRenderedData, setPrevRenderedData] =
|
|
98
|
-
const [globalSearchOp, setGlobalSearchOp] =
|
|
99
|
-
const [searchOp, setSearchOp] =
|
|
100
|
-
const [summariseAvailable, setSummariseAvailable] =
|
|
101
|
-
const [groupedKeys, setGroupedKeys] =
|
|
59
|
+
const [prevRenderedData, setPrevRenderedData] = useState(null);
|
|
60
|
+
const [globalSearchOp, setGlobalSearchOp] = useState("or");
|
|
61
|
+
const [searchOp, setSearchOp] = useState("and");
|
|
62
|
+
const [summariseAvailable, setSummariseAvailable] = useState(false);
|
|
63
|
+
const [groupedKeys, setGroupedKeys] = useState([]);
|
|
102
64
|
// const [changed, setChanged] = useState<string[]>([]);
|
|
103
|
-
const prevData =
|
|
104
|
-
const [isFullScreen, setIsFullScreen] =
|
|
105
|
-
const [fullScreen, setFullScreen] =
|
|
106
|
-
const [isCollapsed, setIsCollapsed] =
|
|
107
|
-
const prevColumns =
|
|
108
|
-
const [inputValue, setInputValue] =
|
|
109
|
-
const [expandedGI, setExpandedGI] =
|
|
110
|
-
const freezeColumnsAvailable =
|
|
111
|
-
const fixedColumns =
|
|
65
|
+
const prevData = useRef(data);
|
|
66
|
+
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
67
|
+
const [fullScreen, setFullScreen] = useState(false);
|
|
68
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
69
|
+
const prevColumns = useRef(null);
|
|
70
|
+
const [inputValue, setInputValue] = useState("");
|
|
71
|
+
const [expandedGI, setExpandedGI] = useState(false);
|
|
72
|
+
const freezeColumnsAvailable = useMemo(() => gridColumns.some((col) => col.freeze), [gridColumns]);
|
|
73
|
+
const fixedColumns = useMemo(() => {
|
|
112
74
|
return gridColumns.filter((col) => col.fixedFilter && col.fixedFilter !== "");
|
|
113
75
|
}, [gridColumns]);
|
|
114
|
-
const [fixedFilterValues, setFixedFilterValues] =
|
|
115
|
-
|
|
76
|
+
const [fixedFilterValues, setFixedFilterValues] = useState({});
|
|
77
|
+
useEffect(() => {
|
|
116
78
|
setSummariseAvailable(isSummarise);
|
|
117
79
|
}, [isSummarise]);
|
|
118
|
-
|
|
80
|
+
useEffect(() => {
|
|
119
81
|
setFullScreen(fullScreenAvailable);
|
|
120
82
|
}, [fullScreenAvailable]);
|
|
121
|
-
|
|
83
|
+
useEffect(() => {
|
|
122
84
|
if (defaultSort) {
|
|
123
85
|
setSortQueries(defaultSort);
|
|
124
86
|
}
|
|
125
87
|
}, [defaultSort]);
|
|
126
|
-
|
|
88
|
+
useEffect(() => {
|
|
127
89
|
let _columns = [...columns];
|
|
128
90
|
if (_columns.length > 0 && data.length > 0) {
|
|
129
91
|
const columnData = _columns.reduce((acc, item) => {
|
|
@@ -131,7 +93,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
131
93
|
const values = data.map((row) => { var _a, _b; return (_b = (_a = row === null || row === void 0 ? void 0 : row[item === null || item === void 0 ? void 0 : item.key]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ""; });
|
|
132
94
|
const hasValues = values.some((item) => item !== "");
|
|
133
95
|
if (hasValues) {
|
|
134
|
-
if (values.every((item) => typeof item === "string" &&
|
|
96
|
+
if (values.every((item) => typeof item === "string" && isValidDateFormat(item))) {
|
|
135
97
|
type = "date";
|
|
136
98
|
}
|
|
137
99
|
else if (values.every((item) => typeof item === "number")) {
|
|
@@ -151,12 +113,12 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
151
113
|
}
|
|
152
114
|
setGridColumns(_columns);
|
|
153
115
|
}, [columns, data]);
|
|
154
|
-
|
|
116
|
+
useEffect(() => {
|
|
155
117
|
if (globalSearchOpen) {
|
|
156
118
|
setExpandedGI(true);
|
|
157
119
|
}
|
|
158
120
|
}, [globalSearchOpen]);
|
|
159
|
-
const filteredData =
|
|
121
|
+
const filteredData = useMemo(() => {
|
|
160
122
|
let _filteredData = data.filter((item) => fixedColumns.length > 0
|
|
161
123
|
? Object.keys(fixedFilterValues)
|
|
162
124
|
.filter((key) => fixedColumns.find((col) => col.key === key))
|
|
@@ -178,7 +140,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
178
140
|
? (_b = item[column.key].value) === null || _b === void 0 ? void 0 : _b.toString()
|
|
179
141
|
: "";
|
|
180
142
|
if (query.includes("*") || query.includes("?")) {
|
|
181
|
-
const regex =
|
|
143
|
+
const regex = createRegexFromWildcard(query);
|
|
182
144
|
return regex.test(value);
|
|
183
145
|
}
|
|
184
146
|
switch ((_c = searchQueries[column.key]) === null || _c === void 0 ? void 0 : _c.type) {
|
|
@@ -255,7 +217,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
255
217
|
? (_b = item[column.key].value) === null || _b === void 0 ? void 0 : _b.toString()
|
|
256
218
|
: "";
|
|
257
219
|
if (query.includes("*") || query.includes("?")) {
|
|
258
|
-
const regex =
|
|
220
|
+
const regex = createRegexFromWildcard(query);
|
|
259
221
|
return regex.test(value);
|
|
260
222
|
}
|
|
261
223
|
switch ((_c = searchQueries[column.key]) === null || _c === void 0 ? void 0 : _c.type) {
|
|
@@ -494,38 +456,38 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
494
456
|
setSummariseKeys(_summariseKeys);
|
|
495
457
|
setSummariseDetails(newSummariseDetails);
|
|
496
458
|
};
|
|
497
|
-
const { sortedData, handleSort, sortQueries, setSortQueries } =
|
|
498
|
-
const { paginatedData, currentPage, handleChangePage, handleChangeRowsPerPage, rowsPerPage, } =
|
|
499
|
-
|
|
459
|
+
const { sortedData, handleSort, sortQueries, setSortQueries } = useSort(filteredData, gridColumns, uniqueSearch, multiSorting, withAscii);
|
|
460
|
+
const { paginatedData, currentPage, handleChangePage, handleChangeRowsPerPage, rowsPerPage, } = usePagination(sortedData, defaultRowsPerPage);
|
|
461
|
+
useEffect(() => {
|
|
500
462
|
const keys = Object.keys(summariseKeys);
|
|
501
463
|
if (keys.length > 0 && summariseAvailable) {
|
|
502
464
|
recalculate(summariseKeys);
|
|
503
465
|
}
|
|
504
466
|
}, [paginatedData, sortedData, groupedKeys]);
|
|
505
|
-
const { selectedRows, toggleRowSelection, toggleSelectAll, allRowsSelected, someRowsSelected, } =
|
|
467
|
+
const { selectedRows, toggleRowSelection, toggleSelectAll, allRowsSelected, someRowsSelected, } = useBulkSelect({
|
|
506
468
|
data: sortedData,
|
|
507
469
|
selectedRows: selectedCheckBox,
|
|
508
470
|
setSelectedRows: setSelectedCheckbox,
|
|
509
471
|
});
|
|
510
|
-
const [hasVerticalScroll, setHasVerticalScroll] =
|
|
511
|
-
const [totalPages, setTotalPages] =
|
|
512
|
-
const [rowOpened, setRowOpened] =
|
|
513
|
-
const gridRef =
|
|
514
|
-
const entrieGridRef =
|
|
515
|
-
const headerRef =
|
|
516
|
-
const [groupedData, setGroupedData] =
|
|
517
|
-
const [hugLoading, setHugLoading] =
|
|
518
|
-
const [menuVisible, setMenuVisible] =
|
|
519
|
-
const [dropdownVisible, setDropdownVisible] =
|
|
520
|
-
const [summariseDetails, setSummariseDetails] =
|
|
521
|
-
const [summariseKeys, setSummariseKeys] =
|
|
522
|
-
|
|
472
|
+
const [hasVerticalScroll, setHasVerticalScroll] = useState(false);
|
|
473
|
+
const [totalPages, setTotalPages] = useState(0);
|
|
474
|
+
const [rowOpened, setRowOpened] = useState([]);
|
|
475
|
+
const gridRef = useRef(null);
|
|
476
|
+
const entrieGridRef = useRef(null);
|
|
477
|
+
const headerRef = useRef(null);
|
|
478
|
+
const [groupedData, setGroupedData] = useState([]);
|
|
479
|
+
const [hugLoading, setHugLoading] = useState(false);
|
|
480
|
+
const [menuVisible, setMenuVisible] = useState("");
|
|
481
|
+
const [dropdownVisible, setDropdownVisible] = useState("");
|
|
482
|
+
const [summariseDetails, setSummariseDetails] = useState({});
|
|
483
|
+
const [summariseKeys, setSummariseKeys] = useState({});
|
|
484
|
+
useEffect(() => {
|
|
523
485
|
if (propSummariseKeys) {
|
|
524
486
|
setSummariseKeys(propSummariseKeys);
|
|
525
487
|
}
|
|
526
488
|
}, [propSummariseKeys]);
|
|
527
|
-
const [calculatePosition, setCalculatePosition] =
|
|
528
|
-
const [calculateVisible, setCalculateVisible] =
|
|
489
|
+
const [calculatePosition, setCalculatePosition] = useState({ top: 0, left: 0 });
|
|
490
|
+
const [calculateVisible, setCalculateVisible] = useState("");
|
|
529
491
|
// useEffect(() => {
|
|
530
492
|
// const closeMenu = () => {
|
|
531
493
|
// setCalculatePosition({ top: 0, left: 0 });
|
|
@@ -536,25 +498,25 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
536
498
|
// document.removeEventListener("click", closeMenu);
|
|
537
499
|
// };
|
|
538
500
|
// }, []);
|
|
539
|
-
|
|
501
|
+
useEffect(() => {
|
|
540
502
|
if (menuVisible) {
|
|
541
503
|
setDropdownVisible("");
|
|
542
504
|
setCalculateVisible("");
|
|
543
505
|
}
|
|
544
506
|
}, [menuVisible]);
|
|
545
|
-
|
|
507
|
+
useEffect(() => {
|
|
546
508
|
if (dropdownVisible) {
|
|
547
509
|
setMenuVisible("");
|
|
548
510
|
setCalculateVisible("");
|
|
549
511
|
}
|
|
550
512
|
}, [dropdownVisible]);
|
|
551
|
-
|
|
513
|
+
useEffect(() => {
|
|
552
514
|
if (calculateVisible) {
|
|
553
515
|
setMenuVisible("");
|
|
554
516
|
setDropdownVisible("");
|
|
555
517
|
}
|
|
556
518
|
}, [calculateVisible]);
|
|
557
|
-
|
|
519
|
+
useEffect(() => {
|
|
558
520
|
setFilterColumn(gridColumns.map((column) => {
|
|
559
521
|
if (!Object.keys(column).includes("hidden")) {
|
|
560
522
|
column.hidden = false;
|
|
@@ -632,11 +594,9 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
632
594
|
}
|
|
633
595
|
return flatArray;
|
|
634
596
|
};
|
|
635
|
-
|
|
597
|
+
useEffect(() => {
|
|
636
598
|
if (gridGroupBy && gridGroupBy !== "") {
|
|
637
|
-
console.log(gridGroupBy.split(","));
|
|
638
599
|
const groupedArray = groupByMultipleKeys(sortedData, gridGroupBy.split(","));
|
|
639
|
-
console.log(groupedArray);
|
|
640
600
|
const flatGroupedArray = flattenGroupedData(groupedArray, 1);
|
|
641
601
|
setGroupedData(flatGroupedArray);
|
|
642
602
|
const grouped = flatGroupedArray
|
|
@@ -652,7 +612,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
652
612
|
setGroupedData([]);
|
|
653
613
|
}
|
|
654
614
|
}, [sortedData, gridGroupBy]);
|
|
655
|
-
|
|
615
|
+
useEffect(() => {
|
|
656
616
|
var _a;
|
|
657
617
|
if (rowIndex > -1 && rowIndex < 2) {
|
|
658
618
|
if (gridRef.current) {
|
|
@@ -662,12 +622,12 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
662
622
|
(_a = document
|
|
663
623
|
.getElementById(`column-${rowIndex}-${columnIndex}`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
664
624
|
}, [rowIndex, columnIndex]);
|
|
665
|
-
const [columnWidths, setColumnWidths] =
|
|
666
|
-
const [columnHeights, setColumnHeights] =
|
|
667
|
-
|
|
625
|
+
const [columnWidths, setColumnWidths] = useState({});
|
|
626
|
+
const [columnHeights, setColumnHeights] = useState({});
|
|
627
|
+
useEffect(() => {
|
|
668
628
|
getLoadingState && getLoadingState(hugLoading);
|
|
669
629
|
}, [hugLoading]);
|
|
670
|
-
|
|
630
|
+
useEffect(() => {
|
|
671
631
|
let shouldRender = true;
|
|
672
632
|
const _prevRenderedData = prevRenderedData ? prevRenderedData : [];
|
|
673
633
|
if (_prevRenderedData &&
|
|
@@ -761,7 +721,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
761
721
|
return prev;
|
|
762
722
|
});
|
|
763
723
|
};
|
|
764
|
-
|
|
724
|
+
useEffect(() => {
|
|
765
725
|
const handleKeydown = (event) => {
|
|
766
726
|
const keyButton = ["ArrowRight", "ArrowUp", "ArrowDown", "ArrowLeft"];
|
|
767
727
|
const _data = [...(paginate ? paginatedData : sortedData)];
|
|
@@ -806,8 +766,8 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
806
766
|
window.removeEventListener("keydown", handleKeydown);
|
|
807
767
|
};
|
|
808
768
|
}, [sortedData, paginate, paginatedData]);
|
|
809
|
-
|
|
810
|
-
setTotalPages(
|
|
769
|
+
useEffect(() => {
|
|
770
|
+
setTotalPages(getTotalPages(sortedData.length, rowsPerPage));
|
|
811
771
|
}, [data, sortQueries, rowsPerPage, sortedData.length]);
|
|
812
772
|
const isScrollAlmostAtEnd = (element, threshold = 100) => {
|
|
813
773
|
return (element.scrollHeight - element.scrollTop - element.clientHeight <
|
|
@@ -855,12 +815,13 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
855
815
|
const exportableJson = sortedData.map((item) => {
|
|
856
816
|
const newItem = filterColumns.reduce((acc, column) => {
|
|
857
817
|
if (!ignoredExportItems.includes(column.key) && item[column.key]) {
|
|
858
|
-
acc[column.key] =
|
|
818
|
+
acc[column.key] = formatValue(item[column.key].value, locale, formatOptions);
|
|
859
819
|
}
|
|
860
820
|
return acc;
|
|
861
821
|
}, {});
|
|
862
822
|
return newItem;
|
|
863
823
|
});
|
|
824
|
+
console.log({ exportableJson });
|
|
864
825
|
const worksheet = XLSX.utils.json_to_sheet(exportableJson);
|
|
865
826
|
const workbook = XLSX.utils.book_new();
|
|
866
827
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
|
@@ -869,7 +830,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
869
830
|
type: "array",
|
|
870
831
|
});
|
|
871
832
|
const blob = new Blob([excelBuffer], { type: "application/octet-stream" });
|
|
872
|
-
|
|
833
|
+
saveAs(blob, filename);
|
|
873
834
|
};
|
|
874
835
|
const openSetting = () => {
|
|
875
836
|
setIsOpen(true);
|
|
@@ -901,7 +862,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
901
862
|
setIsCollapsed(true);
|
|
902
863
|
}
|
|
903
864
|
};
|
|
904
|
-
|
|
865
|
+
useEffect(() => {
|
|
905
866
|
const handleFullScreenChange = () => {
|
|
906
867
|
setIsFullScreen(!!document.fullscreenElement);
|
|
907
868
|
};
|
|
@@ -938,7 +899,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
938
899
|
setRowOpened(updatedRowOpened);
|
|
939
900
|
setOpenedRows && setOpenedRows(updatedRowOpened);
|
|
940
901
|
};
|
|
941
|
-
|
|
902
|
+
useEffect(() => {
|
|
942
903
|
if (showHideAvailable ||
|
|
943
904
|
exportAvailable ||
|
|
944
905
|
hasCustomOperation ||
|
|
@@ -965,7 +926,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
965
926
|
expandedGI,
|
|
966
927
|
fixedColumns,
|
|
967
928
|
]);
|
|
968
|
-
|
|
929
|
+
useEffect(() => {
|
|
969
930
|
if (defaultGroupOpen && gridGroupBy !== "" && groupedData.length > 0) {
|
|
970
931
|
let updatedRowOpened = groupedData
|
|
971
932
|
.filter((item) => item.type === "main" && item.level == 1)
|
|
@@ -997,7 +958,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
997
958
|
}
|
|
998
959
|
setRemovalHeight(`${_removalHeight}px`);
|
|
999
960
|
};
|
|
1000
|
-
const [draggingIndex, setDraggingIndex] =
|
|
961
|
+
const [draggingIndex, setDraggingIndex] = useState(null);
|
|
1001
962
|
const handleDragStart = (e, index) => {
|
|
1002
963
|
setDraggingIndex(index);
|
|
1003
964
|
e.dataTransfer.effectAllowed = "move";
|
|
@@ -1035,7 +996,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1035
996
|
});
|
|
1036
997
|
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), filterObj)));
|
|
1037
998
|
};
|
|
1038
|
-
const filterDetails =
|
|
999
|
+
const filterDetails = useMemo(() => {
|
|
1039
1000
|
const filterColumn = gridColumns.reduce((acc, column) => {
|
|
1040
1001
|
const query = searchQueries[column.key];
|
|
1041
1002
|
const uniqeValues = [
|
|
@@ -1098,7 +1059,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1098
1059
|
(filterData === null || filterData === void 0 ? void 0 : filterData.globalInputSearch) !== globalInputSearch,
|
|
1099
1060
|
};
|
|
1100
1061
|
}, [searchQueries, globalInputSearch, uniqueSearch, gridColumns]);
|
|
1101
|
-
const sortDetails =
|
|
1062
|
+
const sortDetails = useMemo(() => {
|
|
1102
1063
|
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1103
1064
|
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
1104
1065
|
if (query) {
|
|
@@ -1122,7 +1083,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1122
1083
|
Object.values(propSortColumn).sort().toString(),
|
|
1123
1084
|
};
|
|
1124
1085
|
}, [sortQueries, gridColumns]);
|
|
1125
|
-
const summarise =
|
|
1086
|
+
const summarise = useMemo(() => {
|
|
1126
1087
|
const summariseColumn = gridColumns.reduce((acc, column) => {
|
|
1127
1088
|
const query = summariseKeys === null || summariseKeys === void 0 ? void 0 : summariseKeys[column.key];
|
|
1128
1089
|
if (query) {
|
|
@@ -1146,10 +1107,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1146
1107
|
Object.values(propSummariseColumn).sort().toString(),
|
|
1147
1108
|
};
|
|
1148
1109
|
}, [summariseKeys, gridColumns]);
|
|
1149
|
-
|
|
1110
|
+
useEffect(() => {
|
|
1150
1111
|
handleChangePage(1);
|
|
1151
1112
|
}, [filterDetails.hasFilters]);
|
|
1152
|
-
|
|
1113
|
+
useEffect(() => {
|
|
1153
1114
|
if (filterData) {
|
|
1154
1115
|
setUniqueSearch(filterData.uniqueSearch);
|
|
1155
1116
|
setGlobalInputSearch(filterData.globalInputSearch);
|
|
@@ -1192,10 +1153,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1192
1153
|
// setGridGroupBy(groupBy);
|
|
1193
1154
|
// }
|
|
1194
1155
|
// };
|
|
1195
|
-
return ((
|
|
1156
|
+
return (_jsxs("div", { style: {
|
|
1196
1157
|
height,
|
|
1197
1158
|
backgroundColor: isFullScreen ? "white" : "transparent",
|
|
1198
|
-
}, className: wrapperClass, ref: entrieGridRef, children: [isOpen && ((
|
|
1159
|
+
}, className: wrapperClass, ref: entrieGridRef, children: [isOpen && (_jsx("div", { style: {
|
|
1199
1160
|
position: "fixed",
|
|
1200
1161
|
width: "100vw",
|
|
1201
1162
|
height: "100vh",
|
|
@@ -1206,7 +1167,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1206
1167
|
left: 0,
|
|
1207
1168
|
zIndex: "9999",
|
|
1208
1169
|
backdropFilter: "blur(2px)",
|
|
1209
|
-
}, onClick: closeSetting, ref: modalContent, children: (
|
|
1170
|
+
}, onClick: closeSetting, ref: modalContent, children: _jsxs("div", { style: {
|
|
1210
1171
|
height: "100vh",
|
|
1211
1172
|
width: "20rem",
|
|
1212
1173
|
background: "#fff",
|
|
@@ -1214,65 +1175,65 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1214
1175
|
display: "flex",
|
|
1215
1176
|
flexDirection: "column",
|
|
1216
1177
|
borderLeft: `1px solid ${borderColor}`,
|
|
1217
|
-
}, children: [(
|
|
1178
|
+
}, children: [_jsx("div", { style: {
|
|
1218
1179
|
borderBottom: `1px solid ${borderColor}`,
|
|
1219
1180
|
width: "100%",
|
|
1220
1181
|
display: "flex",
|
|
1221
1182
|
alignItems: "center",
|
|
1222
1183
|
justifyContent: "center",
|
|
1223
1184
|
padding: "1rem",
|
|
1224
|
-
}, children: "Show/Hide columns" }), (
|
|
1185
|
+
}, children: "Show/Hide columns" }), _jsx("div", { style: { flexGrow: 1, overflow: "auto", padding: "1rem" }, children: filterColumns.map((column) => {
|
|
1225
1186
|
if (!column.fixed) {
|
|
1226
|
-
return ((
|
|
1187
|
+
return (_jsxs("div", { style: {
|
|
1227
1188
|
display: "flex",
|
|
1228
1189
|
alignItems: "center",
|
|
1229
|
-
}, children: [(
|
|
1190
|
+
}, children: [_jsx("input", { type: "checkbox", onChange: (e) => handleColumnChange(e.target.checked, column.key), checked: !column.hidden }), _jsx("div", { style: { marginLeft: "0.25rem" }, children: column.label })] }, column.key));
|
|
1230
1191
|
}
|
|
1231
1192
|
return null;
|
|
1232
|
-
}) }), (
|
|
1193
|
+
}) }), _jsxs("div", { style: {
|
|
1233
1194
|
borderTop: `1px solid ${borderColor}`,
|
|
1234
1195
|
display: "flex",
|
|
1235
1196
|
alignItems: "center",
|
|
1236
1197
|
justifyContent: "space-between",
|
|
1237
1198
|
padding: "1rem",
|
|
1238
|
-
}, children: [(
|
|
1199
|
+
}, children: [_jsx("button", { style: {
|
|
1239
1200
|
borderColor: "#D9D9D9",
|
|
1240
1201
|
borderWidth: 1,
|
|
1241
1202
|
padding: "0.25rem 0.5rem",
|
|
1242
|
-
}, onClick: (e) => closeSetting(e, true), children: "Cancel" }), (
|
|
1203
|
+
}, onClick: (e) => closeSetting(e, true), children: "Cancel" }), _jsx("button", { style: {
|
|
1243
1204
|
borderColor: "#D9D9D9",
|
|
1244
1205
|
borderWidth: 1,
|
|
1245
1206
|
padding: "0.25rem 0.5rem",
|
|
1246
|
-
}, onClick: (e) => saveColumns(), children: "Save" })] })] }) })), (
|
|
1207
|
+
}, onClick: (e) => saveColumns(), children: "Save" })] })] }) })), _jsxs("div", { style: {
|
|
1247
1208
|
padding: "0.25rem",
|
|
1248
|
-
}, id: "grid-action", children: [chips.length > 0 && ((
|
|
1209
|
+
}, id: "grid-action", children: [chips.length > 0 && (_jsxs("div", { style: {
|
|
1249
1210
|
width: "100%",
|
|
1250
1211
|
display: "flex",
|
|
1251
1212
|
alignItems: "center",
|
|
1252
1213
|
flexWrap: "wrap",
|
|
1253
1214
|
marginBottom: "0.5rem",
|
|
1254
|
-
}, children: [(
|
|
1215
|
+
}, children: [_jsx("div", { style: { width: 75 }, children: _jsx(Dropdown, { options: [
|
|
1255
1216
|
{ label: "OR", value: "or" },
|
|
1256
1217
|
{ label: "AND", value: "and" },
|
|
1257
|
-
], placeholder: "", selectedValues: [globalSearchOp], onChange: (selected) => setGlobalSearchOp(selected[0].toString()), searchEnabled: false, dropdownListWidth: 100, className: "h-8", style: { position: "relative", zIndex: 101 } }) }), (
|
|
1218
|
+
], placeholder: "", selectedValues: [globalSearchOp], onChange: (selected) => setGlobalSearchOp(selected[0].toString()), searchEnabled: false, dropdownListWidth: 100, className: "h-8", style: { position: "relative", zIndex: 101 } }) }), _jsx("div", { style: {
|
|
1258
1219
|
width: `calc(100% - 75px)`,
|
|
1259
1220
|
display: "flex",
|
|
1260
1221
|
flexWrap: "wrap",
|
|
1261
|
-
}, children: chips.map((chip) => ((
|
|
1222
|
+
}, children: chips.map((chip) => (_jsx(Button, { className: "epic-btn mx-2", textEleClass: "flex w-full items-center justify-between", text: _jsxs(_Fragment, { children: [_jsx("span", { children: chip }), _jsx("span", { style: {
|
|
1262
1223
|
display: "inline-block",
|
|
1263
1224
|
cursor: "pointer",
|
|
1264
1225
|
marginLeft: "0.5rem",
|
|
1265
|
-
}, onClick: () => removeChip(chip), children: "\u00D7" })] }) }, chip))) })] })), (
|
|
1226
|
+
}, onClick: () => removeChip(chip), children: "\u00D7" })] }) }, chip))) })] })), _jsxs("div", { style: {
|
|
1266
1227
|
display: "flex",
|
|
1267
1228
|
alignItems: "end",
|
|
1268
1229
|
justifyContent: globalSearch || filterDetails.hasFilters || sortDetails.hasSort
|
|
1269
1230
|
? "space-between"
|
|
1270
1231
|
: "end",
|
|
1271
|
-
}, children: [(
|
|
1232
|
+
}, children: [_jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [globalSearch && (_jsx("div", { style: { width: expandedGI ? 300 : "fit-content" }, children: _jsx(GlobalSearchChiProps, { expanded: expandedGI, setExpanded: setExpandedGI, globalInputSearch: globalInputSearch, setGlobalInputSearch: setGlobalInputSearch, chips: chips, setChips: setChips, inputValue: inputValue, setInputValue: setInputValue, shouldClose: !globalSearchOpen }) })), filterDetails.hasFilters && (_jsx("div", { title: "Clear All Filters", onClick: () => clearAllFilter(), style: {
|
|
1272
1233
|
cursor: "pointer",
|
|
1273
1234
|
marginLeft: 10,
|
|
1274
1235
|
color: "var(--clear-color)",
|
|
1275
|
-
}, children: (
|
|
1236
|
+
}, children: _jsx(MdFilterAltOff, { size: 18 }) })), sortDetails.hasSort && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
|
|
1276
1237
|
// setChanged((prev) => [...prev, "sorts"]);
|
|
1277
1238
|
setSortQueries({});
|
|
1278
1239
|
}, style: {
|
|
@@ -1280,7 +1241,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1280
1241
|
marginLeft: 10,
|
|
1281
1242
|
transform: "rotate(-90deg)",
|
|
1282
1243
|
color: "var(--clear-color)",
|
|
1283
|
-
}, children: (
|
|
1244
|
+
}, children: _jsx(TbAntennaBarsOff, { size: 18 }) })), summarise.hasSummarise && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
|
|
1284
1245
|
setSummariseKeys({});
|
|
1285
1246
|
setSummariseDetails({});
|
|
1286
1247
|
// setChanged((prev) => [...prev, "summary"]);
|
|
@@ -1288,15 +1249,15 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1288
1249
|
cursor: "pointer",
|
|
1289
1250
|
marginLeft: 10,
|
|
1290
1251
|
color: "var(--clear-color)",
|
|
1291
|
-
}, children: (
|
|
1252
|
+
}, children: _jsx(TbCalculatorOff, {}) }))] }), _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
|
|
1292
1253
|
cursor: "pointer",
|
|
1293
1254
|
marginLeft: 10,
|
|
1294
|
-
}, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? ((
|
|
1255
|
+
}, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? (_jsx(TbCalculatorFilled, { color: summarizeColor, size: 18 })) : (_jsx(TbCalculator, { size: 18 })) })), showHideAvailable && (_jsx("div", { onClick: openSetting, style: { cursor: "pointer", marginLeft: 10 }, children: SettingIcon ? SettingIcon : _jsx(FiEye, { size: 18 }) })), exportAvailable && (_jsx("div", { onClick: handleExport, style: { cursor: "pointer", marginLeft: 10 }, children: ExportIcon ? ExportIcon : _jsx(FiShare, { size: 16 }) })), fullScreen && (_jsx("div", { onClick: toggleFullScreen, style: { cursor: "pointer", marginLeft: 10 }, children: isFullScreen ? (_jsx(MdFullscreenExit, { size: 20 })) : (_jsx(MdFullscreen, { size: 20 })) })), freezeColumnsAvailable && (_jsx("div", { onClick: toggleCollapse, style: { cursor: "pointer", marginLeft: 10 }, children: isCollapsed ? (_jsx(FiChevronsRight, { size: 20 })) : (_jsx(FiChevronsLeft, { size: 20 })) })), (filterDetails.filtersUpdated ||
|
|
1295
1256
|
sortDetails.sortUpdated ||
|
|
1296
1257
|
summarise.summariseUpdated ||
|
|
1297
1258
|
gridGroupBy !== (groupBy || "")) &&
|
|
1298
1259
|
handleSaveAsView &&
|
|
1299
|
-
saveAsNewView && ((
|
|
1260
|
+
saveAsNewView && (_jsx("div", { onClick: () => handleSaveAsView({
|
|
1300
1261
|
globalInputSearch,
|
|
1301
1262
|
searchQueries,
|
|
1302
1263
|
uniqueSearch,
|
|
@@ -1308,10 +1269,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1308
1269
|
}), style: {
|
|
1309
1270
|
marginLeft: 6,
|
|
1310
1271
|
cursor: "pointer",
|
|
1311
|
-
}, title: "save", children: saveAsViewIcon ? saveAsViewIcon : (
|
|
1272
|
+
}, title: "save", children: saveAsViewIcon ? saveAsViewIcon : _jsx(MdSave, {}) })), hasCustomOperation && customOperation
|
|
1312
1273
|
? customOperation
|
|
1313
1274
|
: hasCustomOperation &&
|
|
1314
|
-
resizable && ((
|
|
1275
|
+
resizable && (_jsx("button", { style: {
|
|
1315
1276
|
color: "#FFFFFF",
|
|
1316
1277
|
marginLeft: 6,
|
|
1317
1278
|
backgroundColor: JSON.stringify(gridColumns) === JSON.stringify(columns)
|
|
@@ -1323,31 +1284,31 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1323
1284
|
cursor: JSON.stringify(gridColumns) === JSON.stringify(columns)
|
|
1324
1285
|
? "not-allowed"
|
|
1325
1286
|
: "",
|
|
1326
|
-
}, disabled: JSON.stringify(gridColumns) === JSON.stringify(columns), onClick: () => updateGridColumns && updateGridColumns(gridColumns), children: "Save preview" }))] })] }), gridGroupBy && ((
|
|
1287
|
+
}, disabled: JSON.stringify(gridColumns) === JSON.stringify(columns), onClick: () => updateGridColumns && updateGridColumns(gridColumns), children: "Save preview" }))] })] }), gridGroupBy && (_jsxs("div", { style: {
|
|
1327
1288
|
width: "100%",
|
|
1328
1289
|
flexWrap: "wrap",
|
|
1329
1290
|
display: "flex",
|
|
1330
1291
|
alignItems: "center",
|
|
1331
1292
|
margin: "0.5rem 0",
|
|
1332
1293
|
rowGap: "0.5rem",
|
|
1333
|
-
}, children: [(
|
|
1294
|
+
}, children: [_jsx("div", { title: "Clear All Groups", onClick: () => {
|
|
1334
1295
|
// setChanged((prev) => [...prev, "groupBy"]);
|
|
1335
1296
|
setGridGroupBy("");
|
|
1336
|
-
}, style: { cursor: "pointer", marginRight: "0.5rem" }, children: (
|
|
1297
|
+
}, style: { cursor: "pointer", marginRight: "0.5rem" }, children: _jsx(MdGroupOff, { size: 18 }) }), gridGroupBy.split(",").map((chip) => (_jsxs("div", { style: {
|
|
1337
1298
|
display: "inline-flex",
|
|
1338
1299
|
alignItems: "center",
|
|
1339
1300
|
padding: "0.25rem",
|
|
1340
1301
|
borderRadius: "0.25rem",
|
|
1341
1302
|
margin: "0 0.25rem",
|
|
1342
1303
|
backgroundColor: chipColor,
|
|
1343
|
-
}, children: [(
|
|
1304
|
+
}, children: [_jsx("span", { children: chip }), _jsx("span", { style: {
|
|
1344
1305
|
display: "inline-block",
|
|
1345
1306
|
cursor: "pointer",
|
|
1346
1307
|
marginLeft: "0.5rem",
|
|
1347
1308
|
}, onClick: () => setGridGroupBy((prev) => prev
|
|
1348
1309
|
.split(",")
|
|
1349
1310
|
.filter((item) => item !== chip)
|
|
1350
|
-
.join(",")), children: "\u00D7" })] }, chip)))] }))] }), (
|
|
1311
|
+
.join(",")), children: "\u00D7" })] }, chip)))] }))] }), _jsx("div", { id: "fixed-filters", style: {
|
|
1351
1312
|
display: "flex",
|
|
1352
1313
|
alignItems: "center",
|
|
1353
1314
|
gap: "0.5rem",
|
|
@@ -1373,10 +1334,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1373
1334
|
});
|
|
1374
1335
|
options = [...new Set(options)];
|
|
1375
1336
|
if (!column.hidden) {
|
|
1376
|
-
return ((
|
|
1337
|
+
return (_jsx("div", { style: {
|
|
1377
1338
|
position: "relative",
|
|
1378
1339
|
width: "18rem",
|
|
1379
|
-
}, children: (
|
|
1340
|
+
}, children: _jsx(Dropdown, { options: options.map((option) => ({
|
|
1380
1341
|
label: option,
|
|
1381
1342
|
value: option,
|
|
1382
1343
|
})), label: column.label, placeholder: "Select", selectedValues: selectedValues, onChange: (selected) => {
|
|
@@ -1404,7 +1365,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1404
1365
|
: undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 mt-2", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
|
|
1405
1366
|
}
|
|
1406
1367
|
return null;
|
|
1407
|
-
}) }), (
|
|
1368
|
+
}) }), _jsxs("div", { style: {
|
|
1408
1369
|
display: "block",
|
|
1409
1370
|
border: gridBorder ? "1px solid #f0f0f0" : "none",
|
|
1410
1371
|
overflow: calculateVisible && gridGroupBy ? "visible" : "auto",
|
|
@@ -1412,7 +1373,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1412
1373
|
whiteSpace: "nowrap",
|
|
1413
1374
|
height: `calc(100% - ${removalHeight})`,
|
|
1414
1375
|
position: "relative",
|
|
1415
|
-
}, onScroll: onScroll, ref: gridRef, children: [(
|
|
1376
|
+
}, 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) => {
|
|
1416
1377
|
let _gridGroupBy = gridGroupBy;
|
|
1417
1378
|
_gridGroupBy = _gridGroupBy.split(",").includes(value)
|
|
1418
1379
|
? _gridGroupBy
|
|
@@ -1422,7 +1383,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1422
1383
|
: [..._gridGroupBy.split(",").filter((item) => item), value].join(",");
|
|
1423
1384
|
setGridGroupBy(_gridGroupBy);
|
|
1424
1385
|
updateGroupBy && updateGroupBy(_gridGroupBy);
|
|
1425
|
-
}, headerDropdownIndex: headerDropdownIndex, updateGridColumns: updateGridColumns, setGridColumns: setGridColumns, widthUnits: widthUnits, gridData: filteredData, checkboxWrapper: checkboxWrapper, onFilter: onFilter, setUniqueSearch: setUniqueSearch, uniqueSearch: uniqueSearch, hugColumnWidths: columnWidths, menuVisible: menuVisible, setMenuVisible: setMenuVisible, dropdownVisible: dropdownVisible, actionsKey: actionsKey, setDropdownVisible: setDropdownVisible, columnSearchOutside: columnSearchOutside, locale: locale, formatOptions: formatOptions }), hugLoading && ((
|
|
1386
|
+
}, headerDropdownIndex: headerDropdownIndex, updateGridColumns: updateGridColumns, setGridColumns: setGridColumns, widthUnits: widthUnits, gridData: filteredData, checkboxWrapper: checkboxWrapper, onFilter: onFilter, setUniqueSearch: setUniqueSearch, uniqueSearch: uniqueSearch, hugColumnWidths: columnWidths, menuVisible: menuVisible, setMenuVisible: setMenuVisible, dropdownVisible: dropdownVisible, actionsKey: actionsKey, setDropdownVisible: setDropdownVisible, columnSearchOutside: columnSearchOutside, locale: locale, formatOptions: formatOptions }), hugLoading && (_jsx("div", { style: {
|
|
1426
1387
|
position: "sticky",
|
|
1427
1388
|
width: "100%",
|
|
1428
1389
|
height: `calc(100% - ${(_a = headerRef === null || headerRef === void 0 ? void 0 : headerRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight}px)`,
|
|
@@ -1435,38 +1396,38 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1435
1396
|
alignItems: "center",
|
|
1436
1397
|
justifyContent: "center",
|
|
1437
1398
|
background: "#fff",
|
|
1438
|
-
}, children: (
|
|
1399
|
+
}, children: _jsx(Loader, { size: 32 }) })), _jsx("div", { id: "table-body", children: gridGroupBy !== "" ? (_jsx(GroupedGridDetails, { locale: locale, formatOptions: formatOptions, groupedData: groupedData, rowOpened: rowOpened, startIndex: startIndex, endIndex: endIndex, alternateRowColor: alternateRowColor, updateRowOpened: updateRowOpened, columnWidths: columnWidths, columnHeights: columnHeights, groupBy: groupBy, widthMode: widthMode, rowKey: rowKey, rowHeight: rowHeight, headerBackground: headerBackground, isSummarise: summariseAvailable, gridGroupBy: gridGroupBy, rowStyle: rowStyle, sortable: sortable, cellStyle: cellStyle, summariseKeys: summariseKeys, summariseDetails: summariseDetails, activeCalculateColor: activeCalculateColor, gridRef: gridRef, setCalculatePosition: setCalculatePosition, calculatePosition: calculatePosition, calculatetextColor: calculatetextColor, setCalculateVisible: setCalculateVisible, calculateVisible: calculateVisible, summariseDisplay: summariseDisplay, recalculate: recalculate, selectedRowStyle: selectedRowStyle, isLoading: isLoading, selectedRow: selectedRow, onRowClick: onRowClick, gridColumns: gridColumns, bulkSelect: bulkSelect, selectedRows: selectedRows, toggleRowSelection: toggleRowSelection, hasVerticalScroll: hasVerticalScroll, setColumnWidths: setColumnWidths, setColumnHeights: setColumnHeights, actionsKey: actionsKey })) : (_jsxs(_Fragment, { children: [(paginate ? paginatedData : sortedData).map((item, index) => {
|
|
1439
1400
|
var _a, _b, _c, _d;
|
|
1440
1401
|
if (paginate) {
|
|
1441
|
-
return ((
|
|
1402
|
+
return (_jsx(GridRow, { item: item, index: index, rowStyle: Object.assign(Object.assign({}, rowStyle), (selectedRow === index ? selectedRowStyle : {})), handleDragStart: handleDragStart, handleDragOver: handleDragOver, handleDrop: handleDrop, draggable: draggable, cellStyle: cellStyle, rowHeight: rowHeight, alternateRowColor: alternateRowColor, bulkSelect: bulkSelect, selectedRows: selectedRows ? selectedRows : new Set([""]), ignoreRowSelect: ignoreRowSelect ? ignoreRowSelect : new Set([""]), toggleRowSelection: toggleRowSelection, columns: gridColumns, widthMode: widthMode, hasVerticalScroll: hasVerticalScroll, onRowClick: onRowClick, loading: isLoading, groupBy: gridGroupBy, rowKey: rowKey, rowIndex: rowIndex, columnIndex: columnIndex, hlBorderColor: hlBorderColor, hugColumnWidths: columnWidths, hugColumnHeights: columnHeights, expandedRow: expandedRow, isExpandable: isExpandable, checkboxWrapper: checkboxWrapper, locale: locale, formatOptions: formatOptions }, String((_b = (_a = item.id) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : index)));
|
|
1442
1403
|
}
|
|
1443
1404
|
else if (index >= startIndex && index <= endIndex) {
|
|
1444
|
-
return ((
|
|
1405
|
+
return (_jsx(GridRow, { item: item, index: index, rowStyle: Object.assign(Object.assign({}, rowStyle), (selectedRow === index ? selectedRowStyle : {})), handleDragStart: handleDragStart, handleDragOver: handleDragOver, handleDrop: handleDrop, draggable: draggable, cellStyle: cellStyle, rowHeight: rowHeight, alternateRowColor: alternateRowColor, bulkSelect: bulkSelect, selectedRows: selectedRows ? selectedRows : new Set([""]), ignoreRowSelect: ignoreRowSelect ? ignoreRowSelect : new Set([""]), toggleRowSelection: toggleRowSelection, columns: gridColumns, widthMode: widthMode, hasVerticalScroll: hasVerticalScroll, onRowClick: onRowClick, loading: isLoading, groupBy: gridGroupBy, rowKey: rowKey, rowIndex: rowIndex, columnIndex: columnIndex, hlBorderColor: hlBorderColor, hugColumnWidths: columnWidths, hugColumnHeights: columnHeights, expandedRow: expandedRow, isExpandable: isExpandable, checkboxWrapper: checkboxWrapper, locale: locale, formatOptions: formatOptions }, String((_d = (_c = item.id) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : index)));
|
|
1445
1406
|
}
|
|
1446
1407
|
}), extraRow && extraRow, (paginate ? paginatedData : sortedData).length === 0 &&
|
|
1447
|
-
typeof extraRow === "undefined" && ((
|
|
1408
|
+
typeof extraRow === "undefined" && (_jsx("div", { style: {
|
|
1448
1409
|
width: "100%",
|
|
1449
1410
|
height: `calc(100% - ${(_d = headerRef === null || headerRef === void 0 ? void 0 : headerRef.current) === null || _d === void 0 ? void 0 : _d.clientHeight}px)`,
|
|
1450
1411
|
display: "flex",
|
|
1451
1412
|
alignItems: "center",
|
|
1452
1413
|
padding: "1rem 0",
|
|
1453
1414
|
justifyContent: "center",
|
|
1454
|
-
}, children: "No Data available" }))] })) }), (rowCount || paginate || summariseAvailable) && ((
|
|
1415
|
+
}, children: "No Data available" }))] })) }), (rowCount || paginate || summariseAvailable) && (_jsx("div", { id: "table-footer", style: {
|
|
1455
1416
|
position: "sticky",
|
|
1456
1417
|
bottom: 0,
|
|
1457
1418
|
background: "var(--row-header-bg)",
|
|
1458
1419
|
}, children: summariseAvailable &&
|
|
1459
1420
|
filteredData.length > 0 &&
|
|
1460
|
-
gridGroupBy === "" && ((
|
|
1421
|
+
gridGroupBy === "" && (_jsx(SummariseDetails, { summariseKeys: summariseKeys, columns: gridColumns, groupBy: gridGroupBy, sortable: sortable, cellStyle: cellStyle, columnWidths: columnWidths, widthMode: widthMode, summariseDetails: summariseDetails, activeCalculateColor: activeCalculateColor, gridRef: gridRef, setCalculatePosition: setCalculatePosition, calculatePosition: calculatePosition, calculatetextColor: calculatetextColor, setCalculateVisible: setCalculateVisible, calculateVisible: calculateVisible, summariseDisplay: summariseDisplay, recalculate: recalculate, actionsKey: actionsKey })) }))] }), paginate && gridGroupBy === "" && (_jsxs("div", { id: "pagination", style: {
|
|
1461
1422
|
display: "flex",
|
|
1462
1423
|
minHeight: "2rem",
|
|
1463
1424
|
alignItems: "center",
|
|
1464
1425
|
width: "100%",
|
|
1465
|
-
}, children: [(
|
|
1426
|
+
}, children: [_jsxs("div", { style: {
|
|
1466
1427
|
textAlign: "left",
|
|
1467
1428
|
paddingLeft: 10,
|
|
1468
1429
|
paddingRight: 10,
|
|
1469
1430
|
fontSize: "inherit",
|
|
1470
|
-
}, children: ["Showing ", sortedData.length, " results", " ", paginate && ((
|
|
1431
|
+
}, children: ["Showing ", sortedData.length, " results", " ", paginate && (_jsxs("span", { children: ["(", currentPage, " of ", totalPages, " pages)"] }))] }), _jsx("div", { style: { marginLeft: "auto" }, children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, handleChangePage: handleChangePage, rowsPerPage: rowsPerPage, handleChangeRowsPerPage: handleChangeRowsPerPage, rowsPerPageOptions: rowsPerPageOptions }) })] }))] }));
|
|
1471
1432
|
};
|
|
1472
|
-
|
|
1433
|
+
export default Grid;
|