pixelize-design-library 1.1.36 → 1.1.38
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/SelectSearch/SelectSearch.js +5 -6
- package/dist/Components/Table/Components/TableBody.d.ts +2 -10
- package/dist/Components/Table/Components/TableBody.js +31 -3
- package/dist/Components/Table/Components/TableHeader.d.ts +2 -16
- package/dist/Components/Table/Components/TableHeader.js +2 -4
- package/dist/Components/Table/Components/TableLoading.d.ts +4 -0
- package/dist/Components/Table/Components/TableLoading.js +10 -0
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Table/Table.js +11 -260
- package/dist/Components/Table/TableProps.d.ts +23 -0
- package/dist/Components/Table/TableToDo.d.ts +2 -0
- package/dist/Components/Table/TableToDo.js +291 -0
- package/dist/Pages/table.js +1 -1
- package/package.json +1 -1
|
@@ -322,10 +322,11 @@ function SelectSearch(_a) {
|
|
|
322
322
|
var inputRef = (0, react_1.useRef)(null);
|
|
323
323
|
var dropdownRef = (0, react_1.useRef)(null);
|
|
324
324
|
var filteredOptions = (0, react_1.useMemo)(function () {
|
|
325
|
-
return options.filter(function (option) {
|
|
326
|
-
return option.label.toLowerCase().includes((inputValue !== null && inputValue !== void 0 ? inputValue : "").toLowerCase());
|
|
327
|
-
});
|
|
325
|
+
return options.filter(function (option) { var _a, _b; return (_a = option.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes((_b = (inputValue !== null && inputValue !== void 0 ? inputValue : "")) === null || _b === void 0 ? void 0 : _b.toLowerCase()); });
|
|
328
326
|
}, [options, inputValue]);
|
|
327
|
+
(0, react_1.useEffect)(function () {
|
|
328
|
+
setInputValue(searchQuery);
|
|
329
|
+
}, [searchQuery]);
|
|
329
330
|
// const handleOptionClick = useCallback(
|
|
330
331
|
// (option: selectOptions) => {
|
|
331
332
|
// if (isMultipleSelect) {
|
|
@@ -390,9 +391,7 @@ function SelectSearch(_a) {
|
|
|
390
391
|
};
|
|
391
392
|
var handleKeyDown = function (e) {
|
|
392
393
|
if (e.key === "Enter") {
|
|
393
|
-
var matchingOption = options.find(function (option) {
|
|
394
|
-
return option.label.toLowerCase() === (inputValue !== null && inputValue !== void 0 ? inputValue : "").toLowerCase();
|
|
395
|
-
});
|
|
394
|
+
var matchingOption = options.find(function (option) { var _a, _b; return ((_a = option.label) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = (inputValue !== null && inputValue !== void 0 ? inputValue : "")) === null || _b === void 0 ? void 0 : _b.toLowerCase()); });
|
|
396
395
|
if (matchingOption) {
|
|
397
396
|
handleOptionClick(matchingOption);
|
|
398
397
|
}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
visibleColumns: Record<string, boolean>;
|
|
5
|
-
startRow: number;
|
|
6
|
-
endRow: number;
|
|
7
|
-
columnWidths: number[];
|
|
8
|
-
handleCheckbox: (selection: string | number) => void;
|
|
9
|
-
selections: (string | number)[];
|
|
10
|
-
};
|
|
11
|
-
declare const TableBody: ({ data, isCheckbox, columns, visibleColumns, startRow, endRow, columnWidths, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, selections, }: TableBodyProps) => React.JSX.Element;
|
|
2
|
+
import { TableBodyPageProps } from "../TableProps";
|
|
3
|
+
declare const TableBody: ({ data, isCheckbox, columns, visibleColumns, startRow, endRow, columnWidths, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, selections, isLoading, onRowClick, }: TableBodyPageProps) => React.JSX.Element;
|
|
12
4
|
export default TableBody;
|
|
@@ -7,12 +7,33 @@ var react_1 = require("@chakra-ui/react");
|
|
|
7
7
|
var react_2 = __importDefault(require("react"));
|
|
8
8
|
var table_1 = require("../../../Utils/table");
|
|
9
9
|
var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
10
|
+
var TableLoading_1 = require("./TableLoading");
|
|
10
11
|
var TableBody = function (_a) {
|
|
11
|
-
var data = _a.data, isCheckbox = _a.isCheckbox, columns = _a.columns, visibleColumns = _a.visibleColumns, startRow = _a.startRow, endRow = _a.endRow, columnWidths = _a.columnWidths, freezedBgColor = _a.freezedBgColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, handleCheckbox = _a.handleCheckbox, selections = _a.selections;
|
|
12
|
+
var data = _a.data, isCheckbox = _a.isCheckbox, columns = _a.columns, visibleColumns = _a.visibleColumns, startRow = _a.startRow, endRow = _a.endRow, columnWidths = _a.columnWidths, freezedBgColor = _a.freezedBgColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, handleCheckbox = _a.handleCheckbox, selections = _a.selections, isLoading = _a.isLoading, onRowClick = _a.onRowClick;
|
|
12
13
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
14
|
+
var handleRowClick = function (row, header) {
|
|
15
|
+
onRowClick && onRowClick(row, header);
|
|
16
|
+
};
|
|
17
|
+
if (isLoading) {
|
|
18
|
+
var totalVisibleColumns = Object.values(visibleColumns).filter(Boolean).length +
|
|
19
|
+
(isCheckbox ? 1 : 0);
|
|
20
|
+
return (react_2.default.createElement(TableLoading_1.TableBodyLoading, { noOfColumns: totalVisibleColumns, borderColor: theme.colors.gray[300] }));
|
|
21
|
+
}
|
|
22
|
+
if (data.length === 0) {
|
|
23
|
+
var totalVisibleColumns = Object.values(visibleColumns).filter(Boolean).length +
|
|
24
|
+
(isCheckbox ? 1 : 0);
|
|
25
|
+
return (react_2.default.createElement(react_1.Tr, { backgroundColor: theme.colors.white },
|
|
26
|
+
react_2.default.createElement(react_1.Td, { colSpan: totalVisibleColumns, textAlign: "center", py: 4 },
|
|
27
|
+
react_2.default.createElement(react_1.Box, { textAlign: "center", fontSize: 14 },
|
|
28
|
+
react_2.default.createElement("p", null, "No data found")))));
|
|
29
|
+
}
|
|
13
30
|
return (react_2.default.createElement(react_2.default.Fragment, null, data.slice(startRow, endRow).map(function (row, index) {
|
|
14
31
|
var _a;
|
|
15
|
-
return (react_2.default.createElement(react_1.Tr, { key: index + 1
|
|
32
|
+
return (react_2.default.createElement(react_1.Tr, { key: index + 1, _hover: {
|
|
33
|
+
"& > td": {
|
|
34
|
+
backgroundColor: theme.colors.gray[100], // Apply hover to all cells
|
|
35
|
+
},
|
|
36
|
+
} },
|
|
16
37
|
isCheckbox && (react_2.default.createElement(react_1.Td, { w: "6", fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: freezedBgColor, position: "sticky", border: noBorders ? "none" : "1px solid ".concat((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.gray[300]), boxSizing: "border-box", left: 0, zIndex: 1, className: "columns sticky-columns" },
|
|
17
38
|
react_2.default.createElement(react_1.Checkbox, { "aria-label": "Select all rows", colorScheme: "gray", backgroundColor: theme.colors.gray[50], borderColor: theme.colors.gray[500], variant: "subtle", onChange: function () { return handleCheckbox(row.id); }, isChecked: selections.includes(row.id) }))),
|
|
18
39
|
columns.map(function (header, headerIndex) {
|
|
@@ -22,7 +43,14 @@ var TableBody = function (_a) {
|
|
|
22
43
|
? (0, table_1.calculateLeftOffset)(columnWidths, headerIndex) +
|
|
23
44
|
(isCheckbox ? 50 : 0)
|
|
24
45
|
: 0;
|
|
25
|
-
return (visibleColumns[header.label] && (react_2.default.createElement(react_1.Td, { key: headerIndex + 1,
|
|
46
|
+
return (visibleColumns[header.label] && (react_2.default.createElement(react_1.Td, { key: headerIndex + 1, onClick: function () {
|
|
47
|
+
return !header.node
|
|
48
|
+
? handleRowClick(row, {
|
|
49
|
+
label: header.label,
|
|
50
|
+
id: header.id,
|
|
51
|
+
})
|
|
52
|
+
: null;
|
|
53
|
+
}, fontSize: 14, fontWeight: 400, position: isFrozen ? "sticky" : undefined, left: isFrozen ? leftOffset : undefined, zIndex: isFrozen ? 1 : 0, backgroundColor: isFrozen
|
|
26
54
|
? freezedBgColor
|
|
27
55
|
: index % 2 === 1
|
|
28
56
|
? theme.colors.backgroundColor.light
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
visibleColumns: Record<string, boolean>;
|
|
5
|
-
handleSort: (label: string, type: "asc" | "desc" | "none") => void;
|
|
6
|
-
activeHeader: string | null;
|
|
7
|
-
isPopoverOpen: boolean;
|
|
8
|
-
closePopover: () => void;
|
|
9
|
-
searchFeatures: (header: string) => React.ReactNode;
|
|
10
|
-
handleHeaderClick: (header: string, search: boolean) => void;
|
|
11
|
-
headerRefs: React.MutableRefObject<(HTMLTableCellElement | null)[]>;
|
|
12
|
-
columnWidths: number[];
|
|
13
|
-
columnsSort: ColumnSortingProps[];
|
|
14
|
-
handleCheckbox: (selection: string | number) => void;
|
|
15
|
-
checked: boolean | "indeterminate";
|
|
16
|
-
};
|
|
17
|
-
declare const TableHeader: ({ columns, isCheckbox, visibleColumns, handleSort, activeHeader, isPopoverOpen, closePopover, searchFeatures, handleHeaderClick, headerRefs, columnWidths, columnsSort, headerBgColor, headerTextColor, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, checked, }: TableHeaderProps) => React.JSX.Element;
|
|
2
|
+
import { TableHeaderPageProps } from "../TableProps";
|
|
3
|
+
declare const TableHeader: ({ columns, isCheckbox, visibleColumns, handleSort, headerRefs, columnWidths, columnsSort, headerBgColor, headerTextColor, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, checked, isLoading, }: TableHeaderPageProps) => React.JSX.Element;
|
|
18
4
|
export default TableHeader;
|
|
@@ -30,13 +30,11 @@ var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
|
30
30
|
var fa_1 = require("react-icons/fa");
|
|
31
31
|
var TableHeader = function (_a) {
|
|
32
32
|
var _b;
|
|
33
|
-
var columns = _a.columns, isCheckbox = _a.isCheckbox, visibleColumns = _a.visibleColumns, handleSort = _a.handleSort,
|
|
34
|
-
// hoveredHeaderIndex,
|
|
35
|
-
handleHeaderClick = _a.handleHeaderClick, headerRefs = _a.headerRefs, columnWidths = _a.columnWidths, columnsSort = _a.columnsSort, headerBgColor = _a.headerBgColor, headerTextColor = _a.headerTextColor, freezedBgColor = _a.freezedBgColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, handleCheckbox = _a.handleCheckbox, checked = _a.checked;
|
|
33
|
+
var columns = _a.columns, isCheckbox = _a.isCheckbox, visibleColumns = _a.visibleColumns, handleSort = _a.handleSort, headerRefs = _a.headerRefs, columnWidths = _a.columnWidths, columnsSort = _a.columnsSort, headerBgColor = _a.headerBgColor, headerTextColor = _a.headerTextColor, freezedBgColor = _a.freezedBgColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, handleCheckbox = _a.handleCheckbox, checked = _a.checked, isLoading = _a.isLoading;
|
|
36
34
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
37
35
|
return (react_2.default.createElement(react_1.Tr, null,
|
|
38
36
|
isCheckbox && (react_2.default.createElement(react_1.Th, { w: "6", fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: freezedBgColor, border: noBorders ? "none" : "1px solid ".concat((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[300]), position: "sticky", className: "columns sticky-columns", left: "0px", zIndex: 1, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)" },
|
|
39
|
-
react_2.default.createElement(react_1.Checkbox, { "aria-label": "Select all rows", colorScheme: "gray", backgroundColor: theme.colors.gray[50], borderColor: theme.colors.gray[500], variant: "subtle", onChange: function () { return handleCheckbox(0); }, isChecked: checked === true, isIndeterminate: checked === "indeterminate" }))),
|
|
37
|
+
react_2.default.createElement(react_1.Checkbox, { "aria-label": "Select all rows", colorScheme: "gray", backgroundColor: theme.colors.gray[50], borderColor: theme.colors.gray[500], variant: "subtle", onChange: function () { return handleCheckbox(0); }, isChecked: isLoading ? false : checked === true, isIndeterminate: checked === "indeterminate" }))),
|
|
40
38
|
columns.map(function (header, index) {
|
|
41
39
|
var _a, _b;
|
|
42
40
|
var isFrozen = header.isFreeze;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TableBodyLoading = void 0;
|
|
6
7
|
var react_1 = __importDefault(require("react"));
|
|
7
8
|
var react_2 = require("@chakra-ui/react");
|
|
8
9
|
var TableLoading = function () {
|
|
@@ -29,3 +30,12 @@ var TableLoading = function () {
|
|
|
29
30
|
react_1.default.createElement(react_2.SkeletonText, { noOfLines: 1, skeletonHeight: "2" })))); })))));
|
|
30
31
|
};
|
|
31
32
|
exports.default = TableLoading;
|
|
33
|
+
var TableBodyLoading = function (_a) {
|
|
34
|
+
var noOfColumns = _a.noOfColumns, borderColor = _a.borderColor;
|
|
35
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, Array.from({ length: 5 }).map(function (_, index) {
|
|
36
|
+
return (react_1.default.createElement(react_2.Tr, null,
|
|
37
|
+
react_1.default.createElement(react_2.Td, { colSpan: noOfColumns, textAlign: "center", border: "1px solid ".concat(borderColor) },
|
|
38
|
+
react_1.default.createElement(react_2.Skeleton, { height: "15px", variant: "shine" }))));
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
exports.TableBodyLoading = TableBodyLoading;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableProps } from "./TableProps";
|
|
3
|
-
export default function Table({ data, columns,
|
|
3
|
+
export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagintaion, onRowClick, }: TableProps): React.JSX.Element;
|
|
@@ -55,28 +55,21 @@ var table_1 = require("../../Utils/table");
|
|
|
55
55
|
var TableHeader_1 = __importDefault(require("./Components/TableHeader"));
|
|
56
56
|
var TableBody_1 = __importDefault(require("./Components/TableBody"));
|
|
57
57
|
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
58
|
-
var TableLoading_1 = __importDefault(require("./Components/TableLoading"));
|
|
59
|
-
// import "./Table.css";
|
|
60
58
|
var defaultPageSize = 5;
|
|
61
59
|
function Table(_a) {
|
|
62
60
|
var _b;
|
|
63
|
-
var data = _a.data, columns = _a.columns,
|
|
61
|
+
var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _c = _a.isCheckbox, isCheckbox = _c === void 0 ? false : _c, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _d = _a.noBorders, noBorders = _d === void 0 ? false : _d, _e = _a.isPagintaion, isPagintaion = _e === void 0 ? true : _e, onRowClick = _a.onRowClick;
|
|
64
62
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var _l = (0, react_4.useState)(null), activeHeader = _l[0], setActiveHeader = _l[1];
|
|
70
|
-
var _m = (0, react_4.useState)({}), searchTerms = _m[0], setSearchTerms = _m[1];
|
|
71
|
-
var _o = (0, react_4.useState)({}), searchOperation = _o[0], setSearchOperation = _o[1];
|
|
72
|
-
var _p = (0, react_4.useState)({}), betweenValues = _p[0], setBetweenValues = _p[1];
|
|
73
|
-
var _q = (0, react_4.useState)(columns.reduce(function (acc, curr) {
|
|
63
|
+
var _f = (0, react_4.useState)([]), selection = _f[0], setSelection = _f[1];
|
|
64
|
+
var _g = (0, react_4.useState)(0), currentPage = _g[0], setCurrentPage = _g[1];
|
|
65
|
+
var _h = (0, react_4.useState)(defaultPageSize), rowsPerPage = _h[0], setRowsPerPage = _h[1];
|
|
66
|
+
var _j = (0, react_4.useState)(columns.reduce(function (acc, curr) {
|
|
74
67
|
var _a;
|
|
75
68
|
return (__assign(__assign({}, acc), (_a = {}, _a[curr.label] = true, _a)));
|
|
76
|
-
}, {})), visibleColumns =
|
|
77
|
-
var
|
|
69
|
+
}, {})), visibleColumns = _j[0], setVisibleColumns = _j[1];
|
|
70
|
+
var _k = (0, react_4.useState)([]), columnWidths = _k[0], setColumnWidths = _k[1];
|
|
78
71
|
var headerRefs = (0, react_1.useRef)([]);
|
|
79
|
-
var
|
|
72
|
+
var _l = (0, react_4.useState)([]), columnsSort = _l[0], setColumnsSort = _l[1];
|
|
80
73
|
(0, react_1.useEffect)(function () {
|
|
81
74
|
// Measure widths after the component mounts
|
|
82
75
|
var widths = headerRefs.current.map(function (ref) { return (ref === null || ref === void 0 ? void 0 : ref.offsetWidth) || 0; });
|
|
@@ -87,24 +80,6 @@ function Table(_a) {
|
|
|
87
80
|
setRowsPerPage(value !== 0 ? value : defaultPageSize);
|
|
88
81
|
setCurrentPage(0);
|
|
89
82
|
};
|
|
90
|
-
// const sortedData = [...data].sort((a, b) => {
|
|
91
|
-
// if (!sortField) return 0;
|
|
92
|
-
// if (a[sortField] < b[sortField]) return sortDirection === "asc" ? -1 : 1;
|
|
93
|
-
// if (a[sortField] > b[sortField]) return sortDirection === "asc" ? 1 : -1;
|
|
94
|
-
// return 0;
|
|
95
|
-
// });
|
|
96
|
-
var getValue = function (header) {
|
|
97
|
-
var value = data.reduce(function (acc, item) {
|
|
98
|
-
var itemValue = item[header];
|
|
99
|
-
if (itemValue !== undefined &&
|
|
100
|
-
itemValue !== null &&
|
|
101
|
-
!acc.includes(itemValue)) {
|
|
102
|
-
acc.push(itemValue);
|
|
103
|
-
}
|
|
104
|
-
return acc;
|
|
105
|
-
}, []);
|
|
106
|
-
return value;
|
|
107
|
-
};
|
|
108
83
|
var handleSort = (0, react_1.useCallback)(function (field, sort) {
|
|
109
84
|
if (!sort)
|
|
110
85
|
return;
|
|
@@ -122,63 +97,6 @@ function Table(_a) {
|
|
|
122
97
|
}
|
|
123
98
|
setColumnsSort(newSortState);
|
|
124
99
|
}, [columnsSort]);
|
|
125
|
-
var handleSearchOperation = function (header, operation) {
|
|
126
|
-
setSearchOperation(function (prev) {
|
|
127
|
-
var _a;
|
|
128
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = operation, _a)));
|
|
129
|
-
});
|
|
130
|
-
var list_ofdata = getValue(header);
|
|
131
|
-
if (operation === "between") {
|
|
132
|
-
var smallestValue_1 = String(Math.min(Number.apply(void 0, list_ofdata)));
|
|
133
|
-
var highestValue_1 = String(Math.max(Number.apply(void 0, list_ofdata)));
|
|
134
|
-
setBetweenValues(function (prev) {
|
|
135
|
-
var _a;
|
|
136
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = { min: smallestValue_1, max: highestValue_1 }, _a)));
|
|
137
|
-
});
|
|
138
|
-
setSearchTerms(function (prev) {
|
|
139
|
-
var _a;
|
|
140
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = "between", _a)));
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
if (operation === "blank" || operation === "notBlank") {
|
|
145
|
-
setSearchTerms(function (prev) {
|
|
146
|
-
var _a;
|
|
147
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = "", _a)));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
setSearchTerms(function (prev) {
|
|
152
|
-
var _a;
|
|
153
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = list_ofdata[0].toString(), _a)));
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
var handleSearch = function (field, term) {
|
|
159
|
-
if (searchOperation[field] === "between") {
|
|
160
|
-
setBetweenValues(function (prev) {
|
|
161
|
-
var _a;
|
|
162
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[field] = { min: term.split("-")[0], max: term.split("-")[1] }, _a)));
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
setSearchTerms(function (prev) {
|
|
167
|
-
var _a;
|
|
168
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[field] = term, _a)));
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
var handleHeaderClick = function (header, search) {
|
|
173
|
-
if (!search) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
setActiveHeader(header);
|
|
177
|
-
setPopoverOpen(true);
|
|
178
|
-
};
|
|
179
|
-
var closePopover = function () {
|
|
180
|
-
setPopoverOpen(false);
|
|
181
|
-
};
|
|
182
100
|
var handleCheckbox = function (id) {
|
|
183
101
|
if (id === 0) {
|
|
184
102
|
if (selection.length === data.length) {
|
|
@@ -198,199 +116,32 @@ function Table(_a) {
|
|
|
198
116
|
(0, react_1.useEffect)(function () {
|
|
199
117
|
onSelection && onSelection(selection);
|
|
200
118
|
}, [selection, onSelection]);
|
|
201
|
-
// const filteredData = sortedData.filter((item) => {
|
|
202
|
-
// return Object.keys(searchTerms).every((key) => {
|
|
203
|
-
// const term = String(searchTerms[key]).toLowerCase();
|
|
204
|
-
// const value = String(item[key]).toLowerCase();
|
|
205
|
-
// const operation = searchOperation[key] || "notBlank";
|
|
206
|
-
// switch (operation) {
|
|
207
|
-
// case "contains":
|
|
208
|
-
// return value.includes(term);
|
|
209
|
-
// case "notContains":
|
|
210
|
-
// return !value.includes(term);
|
|
211
|
-
// case "equals":
|
|
212
|
-
// return value === term;
|
|
213
|
-
// case "notEquals":
|
|
214
|
-
// return value !== term;
|
|
215
|
-
// case "beginsWith":
|
|
216
|
-
// return value.startsWith(term);
|
|
217
|
-
// case "endsWith":
|
|
218
|
-
// return value.endsWith(term);
|
|
219
|
-
// case "greaterThan":
|
|
220
|
-
// return Number(value) > Number(term);
|
|
221
|
-
// case "greaterThanOrEqual":
|
|
222
|
-
// return Number(value) >= Number(term);
|
|
223
|
-
// case "lessThan":
|
|
224
|
-
// return Number(value) < Number(term);
|
|
225
|
-
// case "lessThanOrEqual":
|
|
226
|
-
// return Number(value) <= Number(term);
|
|
227
|
-
// case "between": {
|
|
228
|
-
// const { min, max } = betweenValues[key] || {};
|
|
229
|
-
// return Number(value) >= Number(min) && Number(value) <= Number(max);
|
|
230
|
-
// }
|
|
231
|
-
// case "blank":
|
|
232
|
-
// return value === "";
|
|
233
|
-
// case "notBlank":
|
|
234
|
-
// return value !== "";
|
|
235
|
-
// default:
|
|
236
|
-
// return true;
|
|
237
|
-
// }
|
|
238
|
-
// });
|
|
239
|
-
// });
|
|
240
119
|
var pages = Math.ceil(data.length / rowsPerPage);
|
|
241
120
|
var startRow = currentPage * rowsPerPage;
|
|
242
121
|
var endRow = startRow + rowsPerPage;
|
|
243
|
-
// const hasSelection = selection.length > 0;
|
|
244
|
-
// const indeterminate = hasSelection && selection.length < data.length;
|
|
245
122
|
var tableData = (0, react_1.useMemo)(function () {
|
|
246
123
|
return (0, table_1.SortMultiColumnData)(data, columnsSort);
|
|
247
124
|
}, [data, columnsSort]);
|
|
248
|
-
var searchFeatures = function (header) {
|
|
249
|
-
var _a, _b;
|
|
250
|
-
var fieldType = (0, table_1.getFieldType)(header, data);
|
|
251
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
252
|
-
react_1.default.createElement(react_2.Select, { value: searchOperation[header] || "notBlank", onChange: function (e) { return handleSearchOperation(header, e.target.value); }, style: { background: "#3182ce", color: "white" } },
|
|
253
|
-
react_1.default.createElement("option", { value: "equals" }, "Equals"),
|
|
254
|
-
react_1.default.createElement("option", { value: "notEquals" }, "Does not equal"),
|
|
255
|
-
fieldType === "number" ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
256
|
-
react_1.default.createElement("option", { value: "greaterThan" }, "Greater than"),
|
|
257
|
-
react_1.default.createElement("option", { value: "greaterThanOrEqual" }, "Greater than or equal to"),
|
|
258
|
-
react_1.default.createElement("option", { value: "lessThan" }, "Less than"),
|
|
259
|
-
react_1.default.createElement("option", { value: "lessThanOrEqual" }, "Less than or equal to"),
|
|
260
|
-
react_1.default.createElement("option", { value: "between" }, "Between"))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
261
|
-
react_1.default.createElement("option", { value: "contains" }, "Contains"),
|
|
262
|
-
react_1.default.createElement("option", { value: "notContains" }, "Does not contain"),
|
|
263
|
-
react_1.default.createElement("option", { value: "beginsWith" }, "Begins with"),
|
|
264
|
-
react_1.default.createElement("option", { value: "endsWith" }, "Ends with"))),
|
|
265
|
-
react_1.default.createElement("option", { value: "blank" }, "Blank"),
|
|
266
|
-
react_1.default.createElement("option", { value: "notBlank" }, "Not blank")),
|
|
267
|
-
searchOperation[header] !== undefined &&
|
|
268
|
-
searchOperation[header] === "between" &&
|
|
269
|
-
fieldType === "number" && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
270
|
-
react_1.default.createElement("br", null),
|
|
271
|
-
react_1.default.createElement(react_2.Input, { value: ((_a = betweenValues[header]) === null || _a === void 0 ? void 0 : _a.min) || "", onChange: function (e) {
|
|
272
|
-
setBetweenValues(function (prev) {
|
|
273
|
-
var _a;
|
|
274
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = __assign(__assign({}, prev[header]), { min: e.target.value }), _a)));
|
|
275
|
-
});
|
|
276
|
-
setSearchTerms(function (prev) {
|
|
277
|
-
var _a;
|
|
278
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = "between", _a)));
|
|
279
|
-
});
|
|
280
|
-
}, placeholder: "Min...", background: "white", color: "black" }),
|
|
281
|
-
react_1.default.createElement("br", null),
|
|
282
|
-
react_1.default.createElement("br", null),
|
|
283
|
-
react_1.default.createElement(react_2.Input, { value: ((_b = betweenValues[header]) === null || _b === void 0 ? void 0 : _b.max) || "", onChange: function (e) {
|
|
284
|
-
setBetweenValues(function (prev) {
|
|
285
|
-
var _a;
|
|
286
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = __assign(__assign({}, prev[header]), { max: e.target.value }), _a)));
|
|
287
|
-
});
|
|
288
|
-
setSearchTerms(function (prev) {
|
|
289
|
-
var _a;
|
|
290
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[header] = "between", _a)));
|
|
291
|
-
});
|
|
292
|
-
}, placeholder: "Max...", background: "white", color: "black" }))),
|
|
293
|
-
searchOperation[header] !== undefined &&
|
|
294
|
-
searchOperation[header] !== "between" &&
|
|
295
|
-
searchOperation[header] !== "blank" &&
|
|
296
|
-
searchOperation[header] !== "notBlank" && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
297
|
-
react_1.default.createElement("br", null),
|
|
298
|
-
react_1.default.createElement(react_2.Input, { value: searchTerms[header] || "", onChange: function (e) { return handleSearch(header, e.target.value); }, placeholder: "Search...", background: "white", color: "black" })))));
|
|
299
|
-
};
|
|
300
125
|
var handleColumnVisibilityChange = function (header) {
|
|
301
126
|
setVisibleColumns(function (prev) {
|
|
302
127
|
var _a;
|
|
303
128
|
return (__assign(__assign({}, prev), (_a = {}, _a[header] = !prev[header], _a)));
|
|
304
129
|
});
|
|
305
130
|
};
|
|
306
|
-
// const handleMouseEnter = (index: number) => setHoveredHeaderIndex(index);
|
|
307
|
-
// const handleMouseLeave = () => {
|
|
308
|
-
// setHoveredHeaderIndex(null);
|
|
309
|
-
// closePopover();
|
|
310
|
-
// };
|
|
311
|
-
// const removeSearchOptionTerm = (key: any) => {
|
|
312
|
-
// const newSearchTerms = { ...searchTerms };
|
|
313
|
-
// const newSearchOperation = { ...searchOperation };
|
|
314
|
-
// const newBetweenValues = { ...betweenValues };
|
|
315
|
-
// delete newSearchTerms[key];
|
|
316
|
-
// delete newSearchOperation[key];
|
|
317
|
-
// delete newBetweenValues[key];
|
|
318
|
-
// setSearchTerms(newSearchTerms);
|
|
319
|
-
// setSearchOperation(newSearchOperation);
|
|
320
|
-
// setBetweenValues(newBetweenValues);
|
|
321
|
-
// };
|
|
322
|
-
// const SearchOptions = () => {
|
|
323
|
-
// return (
|
|
324
|
-
// <Wrap>
|
|
325
|
-
// {searchOperation &&
|
|
326
|
-
// Object.keys(searchOperation).map((key, index) => {
|
|
327
|
-
// return (
|
|
328
|
-
// <Tag
|
|
329
|
-
// size="sm"
|
|
330
|
-
// key={index}
|
|
331
|
-
// borderRadius="full"
|
|
332
|
-
// variant="solid"
|
|
333
|
-
// colorScheme="gray"
|
|
334
|
-
// m={1}
|
|
335
|
-
// >
|
|
336
|
-
// <Box display="flex" alignItems="center">
|
|
337
|
-
// <TagLabel>{key}</TagLabel>
|
|
338
|
-
// <TagLabel mx={2}>{searchOperation[key]}</TagLabel>
|
|
339
|
-
// {searchOperation[key] === "between" ? (
|
|
340
|
-
// <TagLabel>
|
|
341
|
-
// {betweenValues[key]?.min} - {betweenValues[key]?.max}
|
|
342
|
-
// </TagLabel>
|
|
343
|
-
// ) : (
|
|
344
|
-
// <TagLabel>{searchTerms[key]}</TagLabel>
|
|
345
|
-
// )}
|
|
346
|
-
// </Box>
|
|
347
|
-
// <TagCloseButton onClick={() => removeSearchOptionTerm(key)} />
|
|
348
|
-
// </Tag>
|
|
349
|
-
// );
|
|
350
|
-
// })}
|
|
351
|
-
// </Wrap>
|
|
352
|
-
// );
|
|
353
|
-
// };
|
|
354
|
-
// const Export = ({
|
|
355
|
-
// exportOptions,
|
|
356
|
-
// }: {
|
|
357
|
-
// exportOptions: TableProps["exportOptions"];
|
|
358
|
-
// }) => {
|
|
359
|
-
// return (
|
|
360
|
-
// <Select
|
|
361
|
-
// placeholder="Exports"
|
|
362
|
-
// width={160}
|
|
363
|
-
// onChange={(e) => {
|
|
364
|
-
// handleExportChange && handleExportChange(e.target.value);
|
|
365
|
-
// }}
|
|
366
|
-
// value={exportLabel}
|
|
367
|
-
// key={exportLabel}
|
|
368
|
-
// >
|
|
369
|
-
// {exportOptions?.map((option) => (
|
|
370
|
-
// <option key={option.id} value={option.id}>
|
|
371
|
-
// {option.label}
|
|
372
|
-
// </option>
|
|
373
|
-
// ))}
|
|
374
|
-
// </Select>
|
|
375
|
-
// );
|
|
376
|
-
// };
|
|
377
131
|
var RenderTable = function (_a) {
|
|
378
132
|
var _b, _c, _d;
|
|
379
133
|
var columns = _a.columns;
|
|
380
134
|
return (react_1.default.createElement(react_3.Table, { variant: "simple", size: "sm", overflowX: "scroll", minW: "100%", className: "sticky-columns" },
|
|
381
135
|
react_1.default.createElement(react_3.Thead, null,
|
|
382
|
-
react_1.default.createElement(TableHeader_1.default, { columns: columns, isCheckbox: isCheckbox, headerBgColor: headerBgColor !== null && headerBgColor !== void 0 ? headerBgColor : theme.colors.backgroundColor.muted, headerTextColor: headerTextColor !== null && headerTextColor !== void 0 ? headerTextColor : (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[600], freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600], visibleColumns: visibleColumns, handleSort: handleSort,
|
|
136
|
+
react_1.default.createElement(TableHeader_1.default, { columns: columns, isCheckbox: isCheckbox, headerBgColor: headerBgColor !== null && headerBgColor !== void 0 ? headerBgColor : theme.colors.backgroundColor.muted, headerTextColor: headerTextColor !== null && headerTextColor !== void 0 ? headerTextColor : (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[600], freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600], visibleColumns: visibleColumns, handleSort: handleSort, headerRefs: headerRefs, columnWidths: columnWidths, columnsSort: columnsSort, noBorders: noBorders, handleCheckbox: handleCheckbox, isLoading: isLoading, checked: data.length !== 0 && selection.length === data.length
|
|
383
137
|
? true
|
|
384
138
|
: selection.length === 0
|
|
385
139
|
? false
|
|
386
140
|
: "indeterminate" })),
|
|
387
141
|
react_1.default.createElement(react_3.Tbody, null,
|
|
388
|
-
react_1.default.createElement(TableBody_1.default, { data: tableData, columns: columns, startRow: startRow, endRow: endRow, visibleColumns: visibleColumns, isCheckbox: isCheckbox, columnWidths: columnWidths, noBorders: noBorders, freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_d = theme.colors) === null || _d === void 0 ? void 0 : _d.gray[600], handleCheckbox: handleCheckbox, selections: selection }))));
|
|
142
|
+
react_1.default.createElement(TableBody_1.default, { data: tableData, columns: columns, startRow: startRow, endRow: endRow, visibleColumns: visibleColumns, isCheckbox: isCheckbox, columnWidths: columnWidths, noBorders: noBorders, freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_d = theme.colors) === null || _d === void 0 ? void 0 : _d.gray[600], handleCheckbox: handleCheckbox, selections: selection, isLoading: isLoading, onRowClick: onRowClick }))));
|
|
389
143
|
};
|
|
390
|
-
if (isLoading)
|
|
391
|
-
return react_1.default.createElement(TableLoading_1.default, null);
|
|
392
144
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
393
|
-
react_1.default.createElement("br", null),
|
|
394
145
|
react_1.default.createElement(react_2.TableContainer, { sx: {
|
|
395
146
|
borderRadius: "10px 0 0 10px",
|
|
396
147
|
borderWidth: "0px 0px 0px 5px",
|
|
@@ -398,6 +149,6 @@ function Table(_a) {
|
|
|
398
149
|
boxShadow: theme.shadows.lg,
|
|
399
150
|
} },
|
|
400
151
|
react_1.default.createElement(RenderTable, { columns: columns })),
|
|
401
|
-
isPagintaion && (react_1.default.createElement(Pagination_1.default, { columns: columns, currentPage: currentPage, setCurrentPage: setCurrentPage, rowsPerPage: rowsPerPage, pages: pages, paginationText: "".concat(startRow + 1, " to ").concat(endRow, " of ").concat(data.length), handlePageSizeChange: handlePageSizeChange, dataLength: data.length, visibleColumns: visibleColumns, handleColumnVisibilityChange: handleColumnVisibilityChange, isVisiblity: true }))));
|
|
152
|
+
isPagintaion && !!tableData.length && (react_1.default.createElement(Pagination_1.default, { columns: columns, currentPage: currentPage, setCurrentPage: setCurrentPage, rowsPerPage: rowsPerPage, pages: pages, paginationText: "".concat(startRow + 1, " to ").concat(endRow, " of ").concat(data.length), handlePageSizeChange: handlePageSizeChange, dataLength: data.length, visibleColumns: visibleColumns, handleColumnVisibilityChange: handleColumnVisibilityChange, isVisiblity: true }))));
|
|
402
153
|
}
|
|
403
154
|
exports.default = Table;
|
|
@@ -16,6 +16,7 @@ export type TableProps = {
|
|
|
16
16
|
noBorders?: boolean;
|
|
17
17
|
onSelection?: (selected: (string | number)[]) => void;
|
|
18
18
|
isPagintaion?: boolean;
|
|
19
|
+
onRowClick?: (row: DataObject, header: Record<string, string>) => void;
|
|
19
20
|
};
|
|
20
21
|
export type DataObject = {
|
|
21
22
|
[key: string]: string | number;
|
|
@@ -36,3 +37,25 @@ export type ColumnSortingProps = {
|
|
|
36
37
|
column: string;
|
|
37
38
|
direction: "asc" | "desc" | "none";
|
|
38
39
|
};
|
|
40
|
+
export type TableHeaderPageProps = Pick<TableProps, "columns" | "isCheckbox" | "headerBgColor" | "headerTextColor" | "freezedBgColor" | "freezedTextColor" | "noBorders" | "isLoading"> & {
|
|
41
|
+
visibleColumns: Record<string, boolean>;
|
|
42
|
+
handleSort: (label: string, type: "asc" | "desc" | "none") => void;
|
|
43
|
+
activeHeader?: string | null;
|
|
44
|
+
isPopoverOpen?: boolean;
|
|
45
|
+
closePopover?: () => void;
|
|
46
|
+
searchFeatures?: (header: string) => React.ReactNode;
|
|
47
|
+
handleHeaderClick?: (header: string, search: boolean) => void;
|
|
48
|
+
headerRefs: React.MutableRefObject<(HTMLTableCellElement | null)[]>;
|
|
49
|
+
columnWidths: number[];
|
|
50
|
+
columnsSort: ColumnSortingProps[];
|
|
51
|
+
handleCheckbox: (selection: string | number) => void;
|
|
52
|
+
checked: boolean | "indeterminate";
|
|
53
|
+
};
|
|
54
|
+
export type TableBodyPageProps = Pick<TableProps, "columns" | "isCheckbox" | "data" | "freezedBgColor" | "freezedTextColor" | "noBorders" | "isLoading" | "onRowClick"> & {
|
|
55
|
+
visibleColumns: Record<string, boolean>;
|
|
56
|
+
startRow: number;
|
|
57
|
+
endRow: number;
|
|
58
|
+
columnWidths: number[];
|
|
59
|
+
handleCheckbox: (selection: string | number) => void;
|
|
60
|
+
selections: (string | number)[];
|
|
61
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// const [isPopoverOpen, setPopoverOpen] = useState(false);
|
|
3
|
+
// const [activeHeader, setActiveHeader] = useState<string | null>(null);
|
|
4
|
+
// const [searchTerms, setSearchTerms] = useState<Record<string, string>>({});
|
|
5
|
+
// const [searchOperation, setSearchOperation] = useState<
|
|
6
|
+
// Record<string, string>
|
|
7
|
+
// >({});
|
|
8
|
+
// const [betweenValues, setBetweenValues] = useState<
|
|
9
|
+
// Record<string, { min: string; max: string }>
|
|
10
|
+
// >({});
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.searchFeatures = void 0;
|
|
16
|
+
// const sortedData = [...data].sort((a, b) => {
|
|
17
|
+
// if (!sortField) return 0;
|
|
18
|
+
// if (a[sortField] < b[sortField]) return sortDirection === "asc" ? -1 : 1;
|
|
19
|
+
// if (a[sortField] > b[sortField]) return sortDirection === "asc" ? 1 : -1;
|
|
20
|
+
// return 0;
|
|
21
|
+
// });
|
|
22
|
+
// const getValue = (header: string) => {
|
|
23
|
+
// const value = data.reduce((acc: (string | number)[], item: DataObject) => {
|
|
24
|
+
// const itemValue = item[header];
|
|
25
|
+
// if (
|
|
26
|
+
// itemValue !== undefined &&
|
|
27
|
+
// itemValue !== null &&
|
|
28
|
+
// !acc.includes(itemValue)
|
|
29
|
+
// ) {
|
|
30
|
+
// acc.push(itemValue);
|
|
31
|
+
// }
|
|
32
|
+
// return acc;
|
|
33
|
+
// }, []);
|
|
34
|
+
// return value;
|
|
35
|
+
// };
|
|
36
|
+
// const handleSearchOperation = (header: string, operation: string) => {
|
|
37
|
+
// // setSearchOperation((prev) => ({ ...prev, [header]: operation }));
|
|
38
|
+
// // const list_ofdata = getValue(header);
|
|
39
|
+
// // if (operation === "between") {
|
|
40
|
+
// // const smallestValue = String(Math.min(Number(...list_ofdata)));
|
|
41
|
+
// // const highestValue = String(Math.max(Number(...list_ofdata)));
|
|
42
|
+
// // setBetweenValues((prev) => ({
|
|
43
|
+
// // ...prev,
|
|
44
|
+
// // [header]: { min: smallestValue, max: highestValue },
|
|
45
|
+
// // }));
|
|
46
|
+
// // setSearchTerms((prev) => ({ ...prev, [header]: "between" }));
|
|
47
|
+
// // } else {
|
|
48
|
+
// // if (operation === "blank" || operation === "notBlank") {
|
|
49
|
+
// // setSearchTerms((prev) => ({ ...prev, [header]: "" }));
|
|
50
|
+
// // } else {
|
|
51
|
+
// // setSearchTerms((prev) => ({
|
|
52
|
+
// // ...prev,
|
|
53
|
+
// // [header]: list_ofdata[0].toString(),
|
|
54
|
+
// // }));
|
|
55
|
+
// // }
|
|
56
|
+
// // }
|
|
57
|
+
// };
|
|
58
|
+
// const handleSearch = (field: string, term: string) => {
|
|
59
|
+
// // if (searchOperation[field] === "between") {
|
|
60
|
+
// // setBetweenValues((prev) => ({
|
|
61
|
+
// // ...prev,
|
|
62
|
+
// // [field]: { min: term.split("-")[0], max: term.split("-")[1] },
|
|
63
|
+
// // }));
|
|
64
|
+
// // } else {
|
|
65
|
+
// // setSearchTerms((prev) => ({ ...prev, [field]: term }));
|
|
66
|
+
// // }
|
|
67
|
+
// };
|
|
68
|
+
// const handleHeaderClick = (header: string, search: boolean) => {
|
|
69
|
+
// // if (!search) {
|
|
70
|
+
// // return;
|
|
71
|
+
// // }
|
|
72
|
+
// // setActiveHeader(header);
|
|
73
|
+
// // setPopoverOpen(true);
|
|
74
|
+
// };
|
|
75
|
+
// const closePopover = () => {
|
|
76
|
+
// // setPopoverOpen(false);
|
|
77
|
+
// };
|
|
78
|
+
// const filteredData = sortedData.filter((item) => {
|
|
79
|
+
// return Object.keys(searchTerms).every((key) => {
|
|
80
|
+
// const term = String(searchTerms[key]).toLowerCase();
|
|
81
|
+
// const value = String(item[key]).toLowerCase();
|
|
82
|
+
// const operation = searchOperation[key] || "notBlank";
|
|
83
|
+
// switch (operation) {
|
|
84
|
+
// case "contains":
|
|
85
|
+
// return value.includes(term);
|
|
86
|
+
// case "notContains":
|
|
87
|
+
// return !value.includes(term);
|
|
88
|
+
// case "equals":
|
|
89
|
+
// return value === term;
|
|
90
|
+
// case "notEquals":
|
|
91
|
+
// return value !== term;
|
|
92
|
+
// case "beginsWith":
|
|
93
|
+
// return value.startsWith(term);
|
|
94
|
+
// case "endsWith":
|
|
95
|
+
// return value.endsWith(term);
|
|
96
|
+
// case "greaterThan":
|
|
97
|
+
// return Number(value) > Number(term);
|
|
98
|
+
// case "greaterThanOrEqual":
|
|
99
|
+
// return Number(value) >= Number(term);
|
|
100
|
+
// case "lessThan":
|
|
101
|
+
// return Number(value) < Number(term);
|
|
102
|
+
// case "lessThanOrEqual":
|
|
103
|
+
// return Number(value) <= Number(term);
|
|
104
|
+
// case "between": {
|
|
105
|
+
// const { min, max } = betweenValues[key] || {};
|
|
106
|
+
// return Number(value) >= Number(min) && Number(value) <= Number(max);
|
|
107
|
+
// }
|
|
108
|
+
// case "blank":
|
|
109
|
+
// return value === "";
|
|
110
|
+
// case "notBlank":
|
|
111
|
+
// return value !== "";
|
|
112
|
+
// default:
|
|
113
|
+
// return true;
|
|
114
|
+
// }
|
|
115
|
+
// });
|
|
116
|
+
// });
|
|
117
|
+
var react_1 = __importDefault(require("react"));
|
|
118
|
+
var searchFeatures = function (header) {
|
|
119
|
+
return react_1.default.createElement(react_1.default.Fragment, null, "hi");
|
|
120
|
+
// const fieldType = getFieldType(header, data);
|
|
121
|
+
// return (
|
|
122
|
+
// <>
|
|
123
|
+
// <Select
|
|
124
|
+
// value={searchOperation[header] || "notBlank"}
|
|
125
|
+
// onChange={(e) => handleSearchOperation(header, e.target.value)}
|
|
126
|
+
// style={{ background: "#3182ce", color: "white" }}
|
|
127
|
+
// >
|
|
128
|
+
// <option value="equals">Equals</option>
|
|
129
|
+
// <option value="notEquals">Does not equal</option>
|
|
130
|
+
// {fieldType === "number" ? (
|
|
131
|
+
// <>
|
|
132
|
+
// <option value="greaterThan">Greater than</option>
|
|
133
|
+
// <option value="greaterThanOrEqual">
|
|
134
|
+
// Greater than or equal to
|
|
135
|
+
// </option>
|
|
136
|
+
// <option value="lessThan">Less than</option>
|
|
137
|
+
// <option value="lessThanOrEqual">Less than or equal to</option>
|
|
138
|
+
// <option value="between">Between</option>
|
|
139
|
+
// </>
|
|
140
|
+
// ) : (
|
|
141
|
+
// <>
|
|
142
|
+
// <option value="contains">Contains</option>
|
|
143
|
+
// <option value="notContains">Does not contain</option>
|
|
144
|
+
// <option value="beginsWith">Begins with</option>
|
|
145
|
+
// <option value="endsWith">Ends with</option>
|
|
146
|
+
// </>
|
|
147
|
+
// )}
|
|
148
|
+
// <option value="blank">Blank</option>
|
|
149
|
+
// <option value="notBlank">Not blank</option>
|
|
150
|
+
// </Select>
|
|
151
|
+
// {searchOperation[header] !== undefined &&
|
|
152
|
+
// searchOperation[header] === "between" &&
|
|
153
|
+
// fieldType === "number" && (
|
|
154
|
+
// <>
|
|
155
|
+
// <br />
|
|
156
|
+
// <Input
|
|
157
|
+
// value={betweenValues[header]?.min || ""}
|
|
158
|
+
// onChange={(e) => {
|
|
159
|
+
// setBetweenValues((prev) => ({
|
|
160
|
+
// ...prev,
|
|
161
|
+
// [header]: { ...prev[header], min: e.target.value },
|
|
162
|
+
// }));
|
|
163
|
+
// setSearchTerms((prev) => ({ ...prev, [header]: "between" }));
|
|
164
|
+
// }}
|
|
165
|
+
// placeholder="Min..."
|
|
166
|
+
// background="white"
|
|
167
|
+
// color="black"
|
|
168
|
+
// />
|
|
169
|
+
// <br />
|
|
170
|
+
// <br />
|
|
171
|
+
// <Input
|
|
172
|
+
// value={betweenValues[header]?.max || ""}
|
|
173
|
+
// onChange={(e) => {
|
|
174
|
+
// setBetweenValues((prev) => ({
|
|
175
|
+
// ...prev,
|
|
176
|
+
// [header]: { ...prev[header], max: e.target.value },
|
|
177
|
+
// }));
|
|
178
|
+
// setSearchTerms((prev) => ({ ...prev, [header]: "between" }));
|
|
179
|
+
// }}
|
|
180
|
+
// placeholder="Max..."
|
|
181
|
+
// background="white"
|
|
182
|
+
// color="black"
|
|
183
|
+
// />
|
|
184
|
+
// </>
|
|
185
|
+
// )}
|
|
186
|
+
// {searchOperation[header] !== undefined &&
|
|
187
|
+
// searchOperation[header] !== "between" &&
|
|
188
|
+
// searchOperation[header] !== "blank" &&
|
|
189
|
+
// searchOperation[header] !== "notBlank" && (
|
|
190
|
+
// <>
|
|
191
|
+
// <br />
|
|
192
|
+
// <Input
|
|
193
|
+
// value={searchTerms[header] || ""}
|
|
194
|
+
// onChange={(e) => handleSearch(header, e.target.value)}
|
|
195
|
+
// placeholder="Search..."
|
|
196
|
+
// background="white"
|
|
197
|
+
// color="black"
|
|
198
|
+
// />
|
|
199
|
+
// {/* <br />
|
|
200
|
+
// <select onChange={(e) => console.log("option 1")} style={{ width: "100%", borderRadius: "2px", height: "30px" }}>
|
|
201
|
+
// <option value="">Select an option</option>
|
|
202
|
+
// <option value="option1">Option 1</option>
|
|
203
|
+
// <option value="option2">Option 2</option>
|
|
204
|
+
// <option value="option3">Option 3</option>
|
|
205
|
+
// </select> */}
|
|
206
|
+
// </>
|
|
207
|
+
// )}
|
|
208
|
+
// </>
|
|
209
|
+
// );
|
|
210
|
+
};
|
|
211
|
+
exports.searchFeatures = searchFeatures;
|
|
212
|
+
// const hasSelection = selection.length > 0;
|
|
213
|
+
// const indeterminate = hasSelection && selection.length < data.length;
|
|
214
|
+
// const handleMouseEnter = (index: number) => setHoveredHeaderIndex(index);
|
|
215
|
+
// const handleMouseLeave = () => {
|
|
216
|
+
// setHoveredHeaderIndex(null);
|
|
217
|
+
// closePopover();
|
|
218
|
+
// };
|
|
219
|
+
// const removeSearchOptionTerm = (key: any) => {
|
|
220
|
+
// const newSearchTerms = { ...searchTerms };
|
|
221
|
+
// const newSearchOperation = { ...searchOperation };
|
|
222
|
+
// const newBetweenValues = { ...betweenValues };
|
|
223
|
+
// delete newSearchTerms[key];
|
|
224
|
+
// delete newSearchOperation[key];
|
|
225
|
+
// delete newBetweenValues[key];
|
|
226
|
+
// setSearchTerms(newSearchTerms);
|
|
227
|
+
// setSearchOperation(newSearchOperation);
|
|
228
|
+
// setBetweenValues(newBetweenValues);
|
|
229
|
+
// };
|
|
230
|
+
// const SearchOptions = () => {
|
|
231
|
+
// return (
|
|
232
|
+
// <Wrap>
|
|
233
|
+
// {searchOperation &&
|
|
234
|
+
// Object.keys(searchOperation).map((key, index) => {
|
|
235
|
+
// return (
|
|
236
|
+
// <Tag
|
|
237
|
+
// size="sm"
|
|
238
|
+
// key={index}
|
|
239
|
+
// borderRadius="full"
|
|
240
|
+
// variant="solid"
|
|
241
|
+
// colorScheme="gray"
|
|
242
|
+
// m={1}
|
|
243
|
+
// >
|
|
244
|
+
// <Box display="flex" alignItems="center">
|
|
245
|
+
// <TagLabel>{key}</TagLabel>
|
|
246
|
+
// <TagLabel mx={2}>{searchOperation[key]}</TagLabel>
|
|
247
|
+
// {searchOperation[key] === "between" ? (
|
|
248
|
+
// <TagLabel>
|
|
249
|
+
// {betweenValues[key]?.min} - {betweenValues[key]?.max}
|
|
250
|
+
// </TagLabel>
|
|
251
|
+
// ) : (
|
|
252
|
+
// <TagLabel>{searchTerms[key]}</TagLabel>
|
|
253
|
+
// )}
|
|
254
|
+
// </Box>
|
|
255
|
+
// <TagCloseButton onClick={() => removeSearchOptionTerm(key)} />
|
|
256
|
+
// </Tag>
|
|
257
|
+
// );
|
|
258
|
+
// })}
|
|
259
|
+
// </Wrap>
|
|
260
|
+
// );
|
|
261
|
+
// };
|
|
262
|
+
// const Export = ({
|
|
263
|
+
// exportOptions,
|
|
264
|
+
// }: {
|
|
265
|
+
// exportOptions: TableProps["exportOptions"];
|
|
266
|
+
// }) => {
|
|
267
|
+
// return (
|
|
268
|
+
// <Select
|
|
269
|
+
// placeholder="Exports"
|
|
270
|
+
// width={160}
|
|
271
|
+
// onChange={(e) => {
|
|
272
|
+
// handleExportChange && handleExportChange(e.target.value);
|
|
273
|
+
// }}
|
|
274
|
+
// value={exportLabel}
|
|
275
|
+
// key={exportLabel}
|
|
276
|
+
// >
|
|
277
|
+
// {exportOptions?.map((option) => (
|
|
278
|
+
// <option key={option.id} value={option.id}>
|
|
279
|
+
// {option.label}
|
|
280
|
+
// </option>
|
|
281
|
+
// ))}
|
|
282
|
+
// </Select>
|
|
283
|
+
// );
|
|
284
|
+
// };
|
|
285
|
+
/* <Box display="flex" justifyContent="flex-end">
|
|
286
|
+
<SearchOptions />
|
|
287
|
+
{exportOptions && exportOptions.length > 0 && (
|
|
288
|
+
<Export exportOptions={exportOptions} />
|
|
289
|
+
)}
|
|
290
|
+
</Box> */
|
|
291
|
+
// <br />
|
package/dist/Pages/table.js
CHANGED
|
@@ -54,6 +54,6 @@ var column = [
|
|
|
54
54
|
];
|
|
55
55
|
var TableExample = function () {
|
|
56
56
|
return (react_1.default.createElement("div", null,
|
|
57
|
-
react_1.default.createElement(Table_1.default, { columns: column, data: tableData, isCheckbox: true, isVisiblity: false, isLoading: false, noBorders: false, onSelection: function (
|
|
57
|
+
react_1.default.createElement(Table_1.default, { columns: column, data: tableData, isCheckbox: true, isVisiblity: false, isLoading: false, noBorders: false, onSelection: function (checked) { return console.log(checked); }, onRowClick: function (row, header) { return console.log(row, header); } })));
|
|
58
58
|
};
|
|
59
59
|
exports.TableExample = TableExample;
|