@megha-ui/react 1.2.170 → 1.2.172
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 +150 -186
- 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,7 +594,7 @@ 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
599
|
const groupedArray = groupByMultipleKeys(sortedData, gridGroupBy.split(","));
|
|
638
600
|
const flatGroupedArray = flattenGroupedData(groupedArray, 1);
|
|
@@ -650,7 +612,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
650
612
|
setGroupedData([]);
|
|
651
613
|
}
|
|
652
614
|
}, [sortedData, gridGroupBy]);
|
|
653
|
-
|
|
615
|
+
useEffect(() => {
|
|
654
616
|
var _a;
|
|
655
617
|
if (rowIndex > -1 && rowIndex < 2) {
|
|
656
618
|
if (gridRef.current) {
|
|
@@ -660,12 +622,12 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
660
622
|
(_a = document
|
|
661
623
|
.getElementById(`column-${rowIndex}-${columnIndex}`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
662
624
|
}, [rowIndex, columnIndex]);
|
|
663
|
-
const [columnWidths, setColumnWidths] =
|
|
664
|
-
const [columnHeights, setColumnHeights] =
|
|
665
|
-
|
|
625
|
+
const [columnWidths, setColumnWidths] = useState({});
|
|
626
|
+
const [columnHeights, setColumnHeights] = useState({});
|
|
627
|
+
useEffect(() => {
|
|
666
628
|
getLoadingState && getLoadingState(hugLoading);
|
|
667
629
|
}, [hugLoading]);
|
|
668
|
-
|
|
630
|
+
useEffect(() => {
|
|
669
631
|
let shouldRender = true;
|
|
670
632
|
const _prevRenderedData = prevRenderedData ? prevRenderedData : [];
|
|
671
633
|
if (_prevRenderedData &&
|
|
@@ -759,7 +721,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
759
721
|
return prev;
|
|
760
722
|
});
|
|
761
723
|
};
|
|
762
|
-
|
|
724
|
+
useEffect(() => {
|
|
763
725
|
const handleKeydown = (event) => {
|
|
764
726
|
const keyButton = ["ArrowRight", "ArrowUp", "ArrowDown", "ArrowLeft"];
|
|
765
727
|
const _data = [...(paginate ? paginatedData : sortedData)];
|
|
@@ -804,8 +766,8 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
804
766
|
window.removeEventListener("keydown", handleKeydown);
|
|
805
767
|
};
|
|
806
768
|
}, [sortedData, paginate, paginatedData]);
|
|
807
|
-
|
|
808
|
-
setTotalPages(
|
|
769
|
+
useEffect(() => {
|
|
770
|
+
setTotalPages(getTotalPages(sortedData.length, rowsPerPage));
|
|
809
771
|
}, [data, sortQueries, rowsPerPage, sortedData.length]);
|
|
810
772
|
const isScrollAlmostAtEnd = (element, threshold = 100) => {
|
|
811
773
|
return (element.scrollHeight - element.scrollTop - element.clientHeight <
|
|
@@ -852,13 +814,15 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
852
814
|
const filename = exportableFileName || randomFileName;
|
|
853
815
|
const exportableJson = sortedData.map((item) => {
|
|
854
816
|
const newItem = filterColumns.reduce((acc, column) => {
|
|
817
|
+
var _a;
|
|
855
818
|
if (!ignoredExportItems.includes(column.key) && item[column.key]) {
|
|
856
|
-
acc[column.key] =
|
|
819
|
+
acc[column.key] = formatValue(item[column.key].value, (_a = column.dataType) !== null && _a !== void 0 ? _a : "string", locale, formatOptions);
|
|
857
820
|
}
|
|
858
821
|
return acc;
|
|
859
822
|
}, {});
|
|
860
823
|
return newItem;
|
|
861
824
|
});
|
|
825
|
+
console.log({ exportableJson });
|
|
862
826
|
const worksheet = XLSX.utils.json_to_sheet(exportableJson);
|
|
863
827
|
const workbook = XLSX.utils.book_new();
|
|
864
828
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
|
@@ -867,7 +831,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
867
831
|
type: "array",
|
|
868
832
|
});
|
|
869
833
|
const blob = new Blob([excelBuffer], { type: "application/octet-stream" });
|
|
870
|
-
|
|
834
|
+
saveAs(blob, filename);
|
|
871
835
|
};
|
|
872
836
|
const openSetting = () => {
|
|
873
837
|
setIsOpen(true);
|
|
@@ -899,7 +863,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
899
863
|
setIsCollapsed(true);
|
|
900
864
|
}
|
|
901
865
|
};
|
|
902
|
-
|
|
866
|
+
useEffect(() => {
|
|
903
867
|
const handleFullScreenChange = () => {
|
|
904
868
|
setIsFullScreen(!!document.fullscreenElement);
|
|
905
869
|
};
|
|
@@ -936,7 +900,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
936
900
|
setRowOpened(updatedRowOpened);
|
|
937
901
|
setOpenedRows && setOpenedRows(updatedRowOpened);
|
|
938
902
|
};
|
|
939
|
-
|
|
903
|
+
useEffect(() => {
|
|
940
904
|
if (showHideAvailable ||
|
|
941
905
|
exportAvailable ||
|
|
942
906
|
hasCustomOperation ||
|
|
@@ -963,7 +927,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
963
927
|
expandedGI,
|
|
964
928
|
fixedColumns,
|
|
965
929
|
]);
|
|
966
|
-
|
|
930
|
+
useEffect(() => {
|
|
967
931
|
if (defaultGroupOpen && gridGroupBy !== "" && groupedData.length > 0) {
|
|
968
932
|
let updatedRowOpened = groupedData
|
|
969
933
|
.filter((item) => item.type === "main" && item.level == 1)
|
|
@@ -995,7 +959,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
995
959
|
}
|
|
996
960
|
setRemovalHeight(`${_removalHeight}px`);
|
|
997
961
|
};
|
|
998
|
-
const [draggingIndex, setDraggingIndex] =
|
|
962
|
+
const [draggingIndex, setDraggingIndex] = useState(null);
|
|
999
963
|
const handleDragStart = (e, index) => {
|
|
1000
964
|
setDraggingIndex(index);
|
|
1001
965
|
e.dataTransfer.effectAllowed = "move";
|
|
@@ -1033,7 +997,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1033
997
|
});
|
|
1034
998
|
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), filterObj)));
|
|
1035
999
|
};
|
|
1036
|
-
const filterDetails =
|
|
1000
|
+
const filterDetails = useMemo(() => {
|
|
1037
1001
|
const filterColumn = gridColumns.reduce((acc, column) => {
|
|
1038
1002
|
const query = searchQueries[column.key];
|
|
1039
1003
|
const uniqeValues = [
|
|
@@ -1096,7 +1060,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1096
1060
|
(filterData === null || filterData === void 0 ? void 0 : filterData.globalInputSearch) !== globalInputSearch,
|
|
1097
1061
|
};
|
|
1098
1062
|
}, [searchQueries, globalInputSearch, uniqueSearch, gridColumns]);
|
|
1099
|
-
const sortDetails =
|
|
1063
|
+
const sortDetails = useMemo(() => {
|
|
1100
1064
|
const sortColumn = gridColumns.reduce((acc, column) => {
|
|
1101
1065
|
const query = sortQueries === null || sortQueries === void 0 ? void 0 : sortQueries[column.key];
|
|
1102
1066
|
if (query) {
|
|
@@ -1120,7 +1084,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1120
1084
|
Object.values(propSortColumn).sort().toString(),
|
|
1121
1085
|
};
|
|
1122
1086
|
}, [sortQueries, gridColumns]);
|
|
1123
|
-
const summarise =
|
|
1087
|
+
const summarise = useMemo(() => {
|
|
1124
1088
|
const summariseColumn = gridColumns.reduce((acc, column) => {
|
|
1125
1089
|
const query = summariseKeys === null || summariseKeys === void 0 ? void 0 : summariseKeys[column.key];
|
|
1126
1090
|
if (query) {
|
|
@@ -1144,10 +1108,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1144
1108
|
Object.values(propSummariseColumn).sort().toString(),
|
|
1145
1109
|
};
|
|
1146
1110
|
}, [summariseKeys, gridColumns]);
|
|
1147
|
-
|
|
1111
|
+
useEffect(() => {
|
|
1148
1112
|
handleChangePage(1);
|
|
1149
1113
|
}, [filterDetails.hasFilters]);
|
|
1150
|
-
|
|
1114
|
+
useEffect(() => {
|
|
1151
1115
|
if (filterData) {
|
|
1152
1116
|
setUniqueSearch(filterData.uniqueSearch);
|
|
1153
1117
|
setGlobalInputSearch(filterData.globalInputSearch);
|
|
@@ -1190,10 +1154,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1190
1154
|
// setGridGroupBy(groupBy);
|
|
1191
1155
|
// }
|
|
1192
1156
|
// };
|
|
1193
|
-
return ((
|
|
1157
|
+
return (_jsxs("div", { style: {
|
|
1194
1158
|
height,
|
|
1195
1159
|
backgroundColor: isFullScreen ? "white" : "transparent",
|
|
1196
|
-
}, className: wrapperClass, ref: entrieGridRef, children: [isOpen && ((
|
|
1160
|
+
}, className: wrapperClass, ref: entrieGridRef, children: [isOpen && (_jsx("div", { style: {
|
|
1197
1161
|
position: "fixed",
|
|
1198
1162
|
width: "100vw",
|
|
1199
1163
|
height: "100vh",
|
|
@@ -1204,7 +1168,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1204
1168
|
left: 0,
|
|
1205
1169
|
zIndex: "9999",
|
|
1206
1170
|
backdropFilter: "blur(2px)",
|
|
1207
|
-
}, onClick: closeSetting, ref: modalContent, children: (
|
|
1171
|
+
}, onClick: closeSetting, ref: modalContent, children: _jsxs("div", { style: {
|
|
1208
1172
|
height: "100vh",
|
|
1209
1173
|
width: "20rem",
|
|
1210
1174
|
background: "#fff",
|
|
@@ -1212,65 +1176,65 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1212
1176
|
display: "flex",
|
|
1213
1177
|
flexDirection: "column",
|
|
1214
1178
|
borderLeft: `1px solid ${borderColor}`,
|
|
1215
|
-
}, children: [(
|
|
1179
|
+
}, children: [_jsx("div", { style: {
|
|
1216
1180
|
borderBottom: `1px solid ${borderColor}`,
|
|
1217
1181
|
width: "100%",
|
|
1218
1182
|
display: "flex",
|
|
1219
1183
|
alignItems: "center",
|
|
1220
1184
|
justifyContent: "center",
|
|
1221
1185
|
padding: "1rem",
|
|
1222
|
-
}, children: "Show/Hide columns" }), (
|
|
1186
|
+
}, children: "Show/Hide columns" }), _jsx("div", { style: { flexGrow: 1, overflow: "auto", padding: "1rem" }, children: filterColumns.map((column) => {
|
|
1223
1187
|
if (!column.fixed) {
|
|
1224
|
-
return ((
|
|
1188
|
+
return (_jsxs("div", { style: {
|
|
1225
1189
|
display: "flex",
|
|
1226
1190
|
alignItems: "center",
|
|
1227
|
-
}, children: [(
|
|
1191
|
+
}, 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));
|
|
1228
1192
|
}
|
|
1229
1193
|
return null;
|
|
1230
|
-
}) }), (
|
|
1194
|
+
}) }), _jsxs("div", { style: {
|
|
1231
1195
|
borderTop: `1px solid ${borderColor}`,
|
|
1232
1196
|
display: "flex",
|
|
1233
1197
|
alignItems: "center",
|
|
1234
1198
|
justifyContent: "space-between",
|
|
1235
1199
|
padding: "1rem",
|
|
1236
|
-
}, children: [(
|
|
1200
|
+
}, children: [_jsx("button", { style: {
|
|
1237
1201
|
borderColor: "#D9D9D9",
|
|
1238
1202
|
borderWidth: 1,
|
|
1239
1203
|
padding: "0.25rem 0.5rem",
|
|
1240
|
-
}, onClick: (e) => closeSetting(e, true), children: "Cancel" }), (
|
|
1204
|
+
}, onClick: (e) => closeSetting(e, true), children: "Cancel" }), _jsx("button", { style: {
|
|
1241
1205
|
borderColor: "#D9D9D9",
|
|
1242
1206
|
borderWidth: 1,
|
|
1243
1207
|
padding: "0.25rem 0.5rem",
|
|
1244
|
-
}, onClick: (e) => saveColumns(), children: "Save" })] })] }) })), (
|
|
1208
|
+
}, onClick: (e) => saveColumns(), children: "Save" })] })] }) })), _jsxs("div", { style: {
|
|
1245
1209
|
padding: "0.25rem",
|
|
1246
|
-
}, id: "grid-action", children: [chips.length > 0 && ((
|
|
1210
|
+
}, id: "grid-action", children: [chips.length > 0 && (_jsxs("div", { style: {
|
|
1247
1211
|
width: "100%",
|
|
1248
1212
|
display: "flex",
|
|
1249
1213
|
alignItems: "center",
|
|
1250
1214
|
flexWrap: "wrap",
|
|
1251
1215
|
marginBottom: "0.5rem",
|
|
1252
|
-
}, children: [(
|
|
1216
|
+
}, children: [_jsx("div", { style: { width: 75 }, children: _jsx(Dropdown, { options: [
|
|
1253
1217
|
{ label: "OR", value: "or" },
|
|
1254
1218
|
{ label: "AND", value: "and" },
|
|
1255
|
-
], placeholder: "", selectedValues: [globalSearchOp], onChange: (selected) => setGlobalSearchOp(selected[0].toString()), searchEnabled: false, dropdownListWidth: 100, className: "h-8", style: { position: "relative", zIndex: 101 } }) }), (
|
|
1219
|
+
], placeholder: "", selectedValues: [globalSearchOp], onChange: (selected) => setGlobalSearchOp(selected[0].toString()), searchEnabled: false, dropdownListWidth: 100, className: "h-8", style: { position: "relative", zIndex: 101 } }) }), _jsx("div", { style: {
|
|
1256
1220
|
width: `calc(100% - 75px)`,
|
|
1257
1221
|
display: "flex",
|
|
1258
1222
|
flexWrap: "wrap",
|
|
1259
|
-
}, children: chips.map((chip) => ((
|
|
1223
|
+
}, 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: {
|
|
1260
1224
|
display: "inline-block",
|
|
1261
1225
|
cursor: "pointer",
|
|
1262
1226
|
marginLeft: "0.5rem",
|
|
1263
|
-
}, onClick: () => removeChip(chip), children: "\u00D7" })] }) }, chip))) })] })), (
|
|
1227
|
+
}, onClick: () => removeChip(chip), children: "\u00D7" })] }) }, chip))) })] })), _jsxs("div", { style: {
|
|
1264
1228
|
display: "flex",
|
|
1265
1229
|
alignItems: "end",
|
|
1266
1230
|
justifyContent: globalSearch || filterDetails.hasFilters || sortDetails.hasSort
|
|
1267
1231
|
? "space-between"
|
|
1268
1232
|
: "end",
|
|
1269
|
-
}, children: [(
|
|
1233
|
+
}, 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: {
|
|
1270
1234
|
cursor: "pointer",
|
|
1271
1235
|
marginLeft: 10,
|
|
1272
1236
|
color: "var(--clear-color)",
|
|
1273
|
-
}, children: (
|
|
1237
|
+
}, children: _jsx(MdFilterAltOff, { size: 18 }) })), sortDetails.hasSort && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
|
|
1274
1238
|
// setChanged((prev) => [...prev, "sorts"]);
|
|
1275
1239
|
setSortQueries({});
|
|
1276
1240
|
}, style: {
|
|
@@ -1278,7 +1242,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1278
1242
|
marginLeft: 10,
|
|
1279
1243
|
transform: "rotate(-90deg)",
|
|
1280
1244
|
color: "var(--clear-color)",
|
|
1281
|
-
}, children: (
|
|
1245
|
+
}, children: _jsx(TbAntennaBarsOff, { size: 18 }) })), summarise.hasSummarise && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
|
|
1282
1246
|
setSummariseKeys({});
|
|
1283
1247
|
setSummariseDetails({});
|
|
1284
1248
|
// setChanged((prev) => [...prev, "summary"]);
|
|
@@ -1286,15 +1250,15 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1286
1250
|
cursor: "pointer",
|
|
1287
1251
|
marginLeft: 10,
|
|
1288
1252
|
color: "var(--clear-color)",
|
|
1289
|
-
}, children: (
|
|
1253
|
+
}, children: _jsx(TbCalculatorOff, {}) }))] }), _jsxs("div", { style: { display: "flex", alignItems: "center" }, children: [isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
|
|
1290
1254
|
cursor: "pointer",
|
|
1291
1255
|
marginLeft: 10,
|
|
1292
|
-
}, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? ((
|
|
1256
|
+
}, 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 ||
|
|
1293
1257
|
sortDetails.sortUpdated ||
|
|
1294
1258
|
summarise.summariseUpdated ||
|
|
1295
1259
|
gridGroupBy !== (groupBy || "")) &&
|
|
1296
1260
|
handleSaveAsView &&
|
|
1297
|
-
saveAsNewView && ((
|
|
1261
|
+
saveAsNewView && (_jsx("div", { onClick: () => handleSaveAsView({
|
|
1298
1262
|
globalInputSearch,
|
|
1299
1263
|
searchQueries,
|
|
1300
1264
|
uniqueSearch,
|
|
@@ -1306,10 +1270,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1306
1270
|
}), style: {
|
|
1307
1271
|
marginLeft: 6,
|
|
1308
1272
|
cursor: "pointer",
|
|
1309
|
-
}, title: "save", children: saveAsViewIcon ? saveAsViewIcon : (
|
|
1273
|
+
}, title: "save", children: saveAsViewIcon ? saveAsViewIcon : _jsx(MdSave, {}) })), hasCustomOperation && customOperation
|
|
1310
1274
|
? customOperation
|
|
1311
1275
|
: hasCustomOperation &&
|
|
1312
|
-
resizable && ((
|
|
1276
|
+
resizable && (_jsx("button", { style: {
|
|
1313
1277
|
color: "#FFFFFF",
|
|
1314
1278
|
marginLeft: 6,
|
|
1315
1279
|
backgroundColor: JSON.stringify(gridColumns) === JSON.stringify(columns)
|
|
@@ -1321,31 +1285,31 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1321
1285
|
cursor: JSON.stringify(gridColumns) === JSON.stringify(columns)
|
|
1322
1286
|
? "not-allowed"
|
|
1323
1287
|
: "",
|
|
1324
|
-
}, disabled: JSON.stringify(gridColumns) === JSON.stringify(columns), onClick: () => updateGridColumns && updateGridColumns(gridColumns), children: "Save preview" }))] })] }), gridGroupBy && ((
|
|
1288
|
+
}, disabled: JSON.stringify(gridColumns) === JSON.stringify(columns), onClick: () => updateGridColumns && updateGridColumns(gridColumns), children: "Save preview" }))] })] }), gridGroupBy && (_jsxs("div", { style: {
|
|
1325
1289
|
width: "100%",
|
|
1326
1290
|
flexWrap: "wrap",
|
|
1327
1291
|
display: "flex",
|
|
1328
1292
|
alignItems: "center",
|
|
1329
1293
|
margin: "0.5rem 0",
|
|
1330
1294
|
rowGap: "0.5rem",
|
|
1331
|
-
}, children: [(
|
|
1295
|
+
}, children: [_jsx("div", { title: "Clear All Groups", onClick: () => {
|
|
1332
1296
|
// setChanged((prev) => [...prev, "groupBy"]);
|
|
1333
1297
|
setGridGroupBy("");
|
|
1334
|
-
}, style: { cursor: "pointer", marginRight: "0.5rem" }, children: (
|
|
1298
|
+
}, style: { cursor: "pointer", marginRight: "0.5rem" }, children: _jsx(MdGroupOff, { size: 18 }) }), gridGroupBy.split(",").map((chip) => (_jsxs("div", { style: {
|
|
1335
1299
|
display: "inline-flex",
|
|
1336
1300
|
alignItems: "center",
|
|
1337
1301
|
padding: "0.25rem",
|
|
1338
1302
|
borderRadius: "0.25rem",
|
|
1339
1303
|
margin: "0 0.25rem",
|
|
1340
1304
|
backgroundColor: chipColor,
|
|
1341
|
-
}, children: [(
|
|
1305
|
+
}, children: [_jsx("span", { children: chip }), _jsx("span", { style: {
|
|
1342
1306
|
display: "inline-block",
|
|
1343
1307
|
cursor: "pointer",
|
|
1344
1308
|
marginLeft: "0.5rem",
|
|
1345
1309
|
}, onClick: () => setGridGroupBy((prev) => prev
|
|
1346
1310
|
.split(",")
|
|
1347
1311
|
.filter((item) => item !== chip)
|
|
1348
|
-
.join(",")), children: "\u00D7" })] }, chip)))] }))] }), (
|
|
1312
|
+
.join(",")), children: "\u00D7" })] }, chip)))] }))] }), _jsx("div", { id: "fixed-filters", style: {
|
|
1349
1313
|
display: "flex",
|
|
1350
1314
|
alignItems: "center",
|
|
1351
1315
|
gap: "0.5rem",
|
|
@@ -1371,10 +1335,10 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1371
1335
|
});
|
|
1372
1336
|
options = [...new Set(options)];
|
|
1373
1337
|
if (!column.hidden) {
|
|
1374
|
-
return ((
|
|
1338
|
+
return (_jsx("div", { style: {
|
|
1375
1339
|
position: "relative",
|
|
1376
1340
|
width: "18rem",
|
|
1377
|
-
}, children: (
|
|
1341
|
+
}, children: _jsx(Dropdown, { options: options.map((option) => ({
|
|
1378
1342
|
label: option,
|
|
1379
1343
|
value: option,
|
|
1380
1344
|
})), label: column.label, placeholder: "Select", selectedValues: selectedValues, onChange: (selected) => {
|
|
@@ -1402,7 +1366,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1402
1366
|
: undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 mt-2", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
|
|
1403
1367
|
}
|
|
1404
1368
|
return null;
|
|
1405
|
-
}) }), (
|
|
1369
|
+
}) }), _jsxs("div", { style: {
|
|
1406
1370
|
display: "block",
|
|
1407
1371
|
border: gridBorder ? "1px solid #f0f0f0" : "none",
|
|
1408
1372
|
overflow: calculateVisible && gridGroupBy ? "visible" : "auto",
|
|
@@ -1410,7 +1374,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1410
1374
|
whiteSpace: "nowrap",
|
|
1411
1375
|
height: `calc(100% - ${removalHeight})`,
|
|
1412
1376
|
position: "relative",
|
|
1413
|
-
}, onScroll: onScroll, ref: gridRef, children: [(
|
|
1377
|
+
}, 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) => {
|
|
1414
1378
|
let _gridGroupBy = gridGroupBy;
|
|
1415
1379
|
_gridGroupBy = _gridGroupBy.split(",").includes(value)
|
|
1416
1380
|
? _gridGroupBy
|
|
@@ -1420,7 +1384,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1420
1384
|
: [..._gridGroupBy.split(",").filter((item) => item), value].join(",");
|
|
1421
1385
|
setGridGroupBy(_gridGroupBy);
|
|
1422
1386
|
updateGroupBy && updateGroupBy(_gridGroupBy);
|
|
1423
|
-
}, 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 && ((
|
|
1387
|
+
}, 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: {
|
|
1424
1388
|
position: "sticky",
|
|
1425
1389
|
width: "100%",
|
|
1426
1390
|
height: `calc(100% - ${(_a = headerRef === null || headerRef === void 0 ? void 0 : headerRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight}px)`,
|
|
@@ -1433,38 +1397,38 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
1433
1397
|
alignItems: "center",
|
|
1434
1398
|
justifyContent: "center",
|
|
1435
1399
|
background: "#fff",
|
|
1436
|
-
}, children: (
|
|
1400
|
+
}, 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) => {
|
|
1437
1401
|
var _a, _b, _c, _d;
|
|
1438
1402
|
if (paginate) {
|
|
1439
|
-
return ((
|
|
1403
|
+
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)));
|
|
1440
1404
|
}
|
|
1441
1405
|
else if (index >= startIndex && index <= endIndex) {
|
|
1442
|
-
return ((
|
|
1406
|
+
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)));
|
|
1443
1407
|
}
|
|
1444
1408
|
}), extraRow && extraRow, (paginate ? paginatedData : sortedData).length === 0 &&
|
|
1445
|
-
typeof extraRow === "undefined" && ((
|
|
1409
|
+
typeof extraRow === "undefined" && (_jsx("div", { style: {
|
|
1446
1410
|
width: "100%",
|
|
1447
1411
|
height: `calc(100% - ${(_d = headerRef === null || headerRef === void 0 ? void 0 : headerRef.current) === null || _d === void 0 ? void 0 : _d.clientHeight}px)`,
|
|
1448
1412
|
display: "flex",
|
|
1449
1413
|
alignItems: "center",
|
|
1450
1414
|
padding: "1rem 0",
|
|
1451
1415
|
justifyContent: "center",
|
|
1452
|
-
}, children: "No Data available" }))] })) }), (rowCount || paginate || summariseAvailable) && ((
|
|
1416
|
+
}, children: "No Data available" }))] })) }), (rowCount || paginate || summariseAvailable) && (_jsx("div", { id: "table-footer", style: {
|
|
1453
1417
|
position: "sticky",
|
|
1454
1418
|
bottom: 0,
|
|
1455
1419
|
background: "var(--row-header-bg)",
|
|
1456
1420
|
}, children: summariseAvailable &&
|
|
1457
1421
|
filteredData.length > 0 &&
|
|
1458
|
-
gridGroupBy === "" && ((
|
|
1422
|
+
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: {
|
|
1459
1423
|
display: "flex",
|
|
1460
1424
|
minHeight: "2rem",
|
|
1461
1425
|
alignItems: "center",
|
|
1462
1426
|
width: "100%",
|
|
1463
|
-
}, children: [(
|
|
1427
|
+
}, children: [_jsxs("div", { style: {
|
|
1464
1428
|
textAlign: "left",
|
|
1465
1429
|
paddingLeft: 10,
|
|
1466
1430
|
paddingRight: 10,
|
|
1467
1431
|
fontSize: "inherit",
|
|
1468
|
-
}, children: ["Showing ", sortedData.length, " results", " ", paginate && ((
|
|
1432
|
+
}, 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 }) })] }))] }));
|
|
1469
1433
|
};
|
|
1470
|
-
|
|
1434
|
+
export default Grid;
|