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