pixelize-design-library 1.1.33 → 1.1.35
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/App.js +1 -1
- package/dist/Components/KaTable/CustomHeader.d.ts +12 -1
- package/dist/Components/KaTable/CustomHeader.js +38 -75
- package/dist/Components/KaTable/KaTable.d.ts +1 -1
- package/dist/Components/KaTable/KaTable.js +48 -13
- package/dist/Components/KaTable/KaTableProps.d.ts +4 -3
- package/dist/Components/KaTable/SelectionHeader.js +4 -2
- package/dist/Components/KaTable/ka-table.css +3 -9
- package/dist/Components/KaTable/useMergedChildComponents.d.ts +13 -1
- package/dist/Components/KaTable/useMergedChildComponents.js +53 -28
- package/dist/Components/SideBar/SideBar.js +58 -40
- package/dist/Components/Table/Components/Pagination.d.ts +15 -0
- package/dist/Components/Table/Components/Pagination.js +42 -0
- package/dist/Components/Table/Components/TableBody.d.ts +12 -0
- package/dist/Components/Table/Components/TableBody.js +35 -0
- package/dist/Components/Table/Components/TableHeader.d.ts +18 -0
- package/dist/Components/Table/Components/TableHeader.js +115 -0
- package/dist/Components/Table/Components/TableLoading.d.ts +3 -0
- package/dist/Components/Table/Components/TableLoading.js +31 -0
- package/dist/Components/Table/Table.css +29 -0
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Table/Table.js +231 -217
- package/dist/Components/Table/TableProps.d.ts +20 -17
- package/dist/Constants/Sidebar.d.ts +15 -0
- package/dist/Constants/Sidebar.js +18 -0
- package/dist/Layout.js +5 -1
- package/dist/Pages/KaTableExample.js +19 -2
- package/dist/Pages/katable.d.ts +3 -0
- package/dist/Pages/katable.js +194 -0
- package/dist/Pages/table.d.ts +2 -0
- package/dist/Pages/table.js +59 -0
- package/dist/Theme/fonts.d.ts +1 -0
- package/dist/Theme/fonts.js +8 -3
- package/dist/Utils/common.d.ts +7 -0
- package/dist/Utils/common.js +64 -0
- package/dist/Utils/table.d.ts +9 -0
- package/dist/Utils/table.js +64 -0
- package/dist/bootstrap.js +1 -2
- package/package.json +2 -1
- package/dist/Theme/Default/fonts.d.ts +0 -35
- package/dist/Theme/Default/fonts.js +0 -37
package/dist/App.js
CHANGED
|
@@ -91,7 +91,7 @@ function App() {
|
|
|
91
91
|
react_1.default.createElement(Loading_1.default, { text: "PIXELIZE CRM", isLoading: false, onlytext: true }),
|
|
92
92
|
react_1.default.createElement(react_2.Flex, null,
|
|
93
93
|
react_1.default.createElement(react_2.Box, null,
|
|
94
|
-
react_1.default.createElement(SideBar_1.default, { menus: menu, activeMenu: activeMenu, handleMenuClick: handleMenuClick, toggle: toggle, changeToggle: function () { return changeToggle(!toggle); }, logo: "https://
|
|
94
|
+
react_1.default.createElement(SideBar_1.default, { menus: menu, activeMenu: activeMenu, handleMenuClick: handleMenuClick, toggle: toggle, changeToggle: function () { return changeToggle(!toggle); }, logo: "https://play-lh.googleusercontent.com/Fro4e_osoDhhrjgiZ_Y2C5FNXBMWvrb4rGpmkM1PDAcUPXeiAlPCq7NeaT4Q6NRUxRqo", companyName: "PIXELIZE" })),
|
|
95
95
|
react_1.default.createElement(react_2.Box, { flex: "1", maxWidth: width, overflow: "hidden" },
|
|
96
96
|
react_1.default.createElement(NavigationBar_1.default, { userAvathar: "https://bit.ly/dan-abramo", userName: "PIXELIZE", navMenu: navmenus, handleNavOnClick: handleNavOnClick, handleLogout: handleLogout, logoutText: "Logout", key: "navbar", moreIcon: react_1.default.createElement(fi_1.FiCalendar, null) }),
|
|
97
97
|
react_1.default.createElement("br", null),
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
type CustomHeaderProps = {
|
|
3
|
+
column: any;
|
|
4
|
+
onSortChange?: (sortState: string, columnName: string) => void;
|
|
5
|
+
menuItems?: Array<{
|
|
6
|
+
label: string;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
submenu?: any[];
|
|
9
|
+
}>;
|
|
10
|
+
isSort?: boolean;
|
|
11
|
+
sortDirection: string;
|
|
12
|
+
};
|
|
13
|
+
declare const CustomHeader: React.MemoExoticComponent<({ column, onSortChange, menuItems, isSort, sortDirection, }: CustomHeaderProps) => React.JSX.Element>;
|
|
3
14
|
export default CustomHeader;
|
|
@@ -27,80 +27,43 @@ var react_1 = __importStar(require("react"));
|
|
|
27
27
|
var react_2 = require("@chakra-ui/react");
|
|
28
28
|
var bs_1 = require("react-icons/bs");
|
|
29
29
|
var fa_1 = require("react-icons/fa");
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var handleMenuItemClick = function (action) {
|
|
51
|
-
if (onMenuItemClick) {
|
|
52
|
-
onMenuItemClick(action, column);
|
|
53
|
-
}
|
|
54
|
-
setSubmenuOpen(false);
|
|
55
|
-
};
|
|
56
|
-
var handleSortClick = function () {
|
|
57
|
-
setSortState(function (prevState) {
|
|
58
|
-
var newState = prevState === "none" ? "asc" : prevState === "asc" ? "desc" : "none";
|
|
59
|
-
if (onSortChange) {
|
|
60
|
-
onSortChange(newState, column.title);
|
|
61
|
-
}
|
|
62
|
-
return newState;
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
return (react_1.default.createElement("div", { onMouseEnter: onOpen, onMouseLeave: onClose },
|
|
66
|
-
react_1.default.createElement(react_2.Box, { style: {
|
|
67
|
-
display: "flex",
|
|
68
|
-
justifyContent: "space-between",
|
|
69
|
-
alignItems: "center",
|
|
70
|
-
} },
|
|
71
|
-
react_1.default.createElement(react_2.Box, { sx: { fontWeight: "bold" } }, column.title),
|
|
72
|
-
react_1.default.createElement(react_2.Box, { style: {
|
|
73
|
-
display: "flex",
|
|
74
|
-
justifyContent: "space-between",
|
|
75
|
-
alignItems: "center",
|
|
76
|
-
} }, menuItems && (react_1.default.createElement(react_2.Menu, null,
|
|
77
|
-
isOpen && (react_1.default.createElement(react_2.MenuButton, { ref: filterButtonRef, as: react_2.IconButton, "aria-label": "More options", icon: react_1.default.createElement(bs_1.BsThreeDots, null), size: "sm", variant: "ghost", sx: {
|
|
78
|
-
_hover: {
|
|
79
|
-
background: "none",
|
|
80
|
-
},
|
|
81
|
-
_active: {
|
|
82
|
-
background: "none",
|
|
83
|
-
},
|
|
84
|
-
} })),
|
|
30
|
+
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
31
|
+
var CustomHeader = (0, react_1.memo)(function (_a) {
|
|
32
|
+
var column = _a.column, onSortChange = _a.onSortChange, menuItems = _a.menuItems, isSort = _a.isSort, sortDirection = _a.sortDirection;
|
|
33
|
+
var handleSortClick = (0, react_1.useCallback)(function () {
|
|
34
|
+
var sortOrder = "none";
|
|
35
|
+
if (sortDirection === "none")
|
|
36
|
+
sortOrder = "asc";
|
|
37
|
+
else if (sortDirection === "asc")
|
|
38
|
+
sortOrder = "desc";
|
|
39
|
+
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(sortOrder, column.key);
|
|
40
|
+
}, [sortDirection, column.key, onSortChange]);
|
|
41
|
+
return (react_1.default.createElement(react_2.Box, { display: "flex", justifyContent: "space-between", alignItems: "center" },
|
|
42
|
+
react_1.default.createElement(react_2.Box, { fontWeight: "bold" }, column.title),
|
|
43
|
+
react_1.default.createElement(react_2.Flex, { alignItems: "center" },
|
|
44
|
+
isSort && (react_1.default.createElement(SortingIcon, { sortState: sortDirection, handleSortClick: handleSortClick })),
|
|
45
|
+
menuItems && (menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) ? (react_1.default.createElement(react_2.Menu, null,
|
|
46
|
+
react_1.default.createElement(react_2.MenuButton, { as: react_2.IconButton, "aria-label": "Options", icon: react_1.default.createElement(bs_1.BsThreeDots, null), size: "sm", variant: "ghost", _hover: { bg: "none" }, _active: { bg: "none" } }),
|
|
85
47
|
react_1.default.createElement(react_2.Portal, null,
|
|
86
|
-
react_1.default.createElement(react_2.MenuList, {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
48
|
+
react_1.default.createElement(react_2.MenuList, null, menuItems.map(function (item, index) { return (react_1.default.createElement(react_1.default.Fragment, { key: index },
|
|
49
|
+
react_1.default.createElement(react_2.MenuItem, { onClick: function () { return item === null || item === void 0 ? void 0 : item.onClick(); } }, item.label),
|
|
50
|
+
item.submenu && react_1.default.createElement(Submenu, { items: item.submenu }))); }))))) : null)));
|
|
51
|
+
});
|
|
52
|
+
var SortingIcon = (0, react_1.memo)(function (_a) {
|
|
53
|
+
var sortState = _a.sortState, handleSortClick = _a.handleSortClick;
|
|
54
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
55
|
+
return (react_1.default.createElement(react_2.Box, { display: "flex", alignItems: "center", justifyContent: "center", bg: theme.colors.white, borderRadius: "full", cursor: "pointer", w: "24px", h: "24px", onClick: handleSortClick, transition: "transform 0.2s ease-in-out", _hover: { transform: "scale(1.1)" } },
|
|
56
|
+
sortState === "none" && react_1.default.createElement(fa_1.FaSort, { size: 14 }),
|
|
57
|
+
sortState === "asc" && react_1.default.createElement(fa_1.FaCaretUp, { size: 14 }),
|
|
58
|
+
sortState === "desc" && react_1.default.createElement(fa_1.FaCaretDown, { size: 14 })));
|
|
59
|
+
});
|
|
60
|
+
var Submenu = (0, react_1.memo)(function (_a) {
|
|
61
|
+
var items = _a.items;
|
|
62
|
+
return (react_1.default.createElement(react_2.MenuGroup, null, items.map(function (subItem, index) { return (react_1.default.createElement(react_2.MenuItem, { key: index, onClick: function () { return (subItem === null || subItem === void 0 ? void 0 : subItem.onClick) && (subItem === null || subItem === void 0 ? void 0 : subItem.onClick()); }, sx: {
|
|
63
|
+
pl: 6,
|
|
64
|
+
fontSize: "sm",
|
|
65
|
+
color: "gray.600",
|
|
66
|
+
_hover: { bg: "gray.100", color: "gray.800" }, // Hover styles
|
|
67
|
+
} }, subItem.label)); })));
|
|
68
|
+
});
|
|
106
69
|
exports.default = CustomHeader;
|
|
@@ -8,6 +8,6 @@ import * as TableFun from "ka-table";
|
|
|
8
8
|
import "ka-table/style.css";
|
|
9
9
|
import "./ka-table.css";
|
|
10
10
|
import { KaTableProps } from "./KaTableProps";
|
|
11
|
-
declare const _default: React.MemoExoticComponent<({ columns, data, rowKey, Edit, format, filter, childComponents, columnReorder, columnResizing, editableCells, validation, loading, checkSelect, onRowClick, onSelectionChange,
|
|
11
|
+
declare const _default: React.MemoExoticComponent<({ columns, data, rowKey, Edit, format, filter, childComponents, columnReorder, columnResizing, editableCells, validation, loading, checkSelect, onRowClick, onSelectionChange, selected, columnVisibility, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, }: KaTableProps) => React.JSX.Element>;
|
|
12
12
|
export default _default;
|
|
13
13
|
export { TableEnums, TableActionCreator, TableProps, TableModel, TableUtils, TableFun, };
|
|
@@ -22,12 +22,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
25
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
36
|
};
|
|
28
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
38
|
exports.TableFun = exports.TableUtils = exports.TableModel = exports.TableProps = exports.TableActionCreator = exports.TableEnums = void 0;
|
|
30
|
-
var react_1 =
|
|
39
|
+
var react_1 = __importStar(require("react"));
|
|
31
40
|
var ka_table_1 = require("ka-table");
|
|
32
41
|
var TableEnums = __importStar(require("ka-table/enums"));
|
|
33
42
|
exports.TableEnums = TableEnums;
|
|
@@ -44,6 +53,8 @@ exports.TableFun = TableFun;
|
|
|
44
53
|
require("ka-table/style.css");
|
|
45
54
|
require("./ka-table.css");
|
|
46
55
|
var useMergedChildComponents_1 = __importDefault(require("./useMergedChildComponents"));
|
|
56
|
+
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
57
|
+
var table_1 = require("../../Utils/table");
|
|
47
58
|
var selectionCellColumn = {
|
|
48
59
|
key: "select-cell",
|
|
49
60
|
width: 50,
|
|
@@ -52,25 +63,49 @@ var selectionCellColumn = {
|
|
|
52
63
|
className: "select-cell",
|
|
53
64
|
};
|
|
54
65
|
var KaTable = function (_a) {
|
|
55
|
-
var _b;
|
|
56
|
-
var columns = _a.columns, data = _a.data,
|
|
66
|
+
var _b, _c;
|
|
67
|
+
var columns = _a.columns, data = _a.data, _d = _a.rowKey, rowKey = _d === void 0 ? "id" : _d, Edit = _a.Edit,
|
|
57
68
|
// sorting,
|
|
58
69
|
format = _a.format,
|
|
59
70
|
// paging,
|
|
60
|
-
filter = _a.filter, childComponents = _a.childComponents, columnReorder = _a.columnReorder, columnResizing = _a.columnResizing, editableCells = _a.editableCells, validation = _a.validation, loading = _a.loading, checkSelect = _a.checkSelect, onRowClick = _a.onRowClick, onSelectionChange = _a.onSelectionChange,
|
|
71
|
+
filter = _a.filter, childComponents = _a.childComponents, columnReorder = _a.columnReorder, columnResizing = _a.columnResizing, editableCells = _a.editableCells, validation = _a.validation, loading = _a.loading, checkSelect = _a.checkSelect, onRowClick = _a.onRowClick, onSelectionChange = _a.onSelectionChange, selected = _a.selected, columnVisibility = _a.columnVisibility, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor;
|
|
72
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
73
|
+
var _e = (0, react_1.useState)([]), sortState = _e[0], setSortState = _e[1];
|
|
61
74
|
if (checkSelect &&
|
|
62
75
|
!columns.some(function (column) { return column.key === "select-cell"; })) {
|
|
63
76
|
columns.unshift(selectionCellColumn);
|
|
64
77
|
}
|
|
65
78
|
var dataLength = (_b = data === null || data === void 0 ? void 0 : data.length) !== null && _b !== void 0 ? _b : 0;
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
// const columnVisibilitys = columnVisibility ?? false;
|
|
80
|
+
var handleSort = function (sort) {
|
|
81
|
+
setSortState(sort);
|
|
82
|
+
};
|
|
83
|
+
var sortedData = (0, react_1.useMemo)(function () { return (0, table_1.SortMultiColumnData)(__spreadArray([], data, true), sortState); }, [sortState, data]);
|
|
84
|
+
var mergedChildComponents = (0, useMergedChildComponents_1.default)({
|
|
85
|
+
childComponents: childComponents,
|
|
86
|
+
onSortChange: handleSort,
|
|
87
|
+
handleSelection: onSelectionChange,
|
|
88
|
+
rowKey: rowKey,
|
|
89
|
+
onRowClick: onRowClick,
|
|
90
|
+
selected: selected,
|
|
91
|
+
dataLength: dataLength,
|
|
92
|
+
columns: columns,
|
|
93
|
+
headerBgColor: headerBgColor,
|
|
94
|
+
freezedBgColor: freezedBgColor,
|
|
95
|
+
headerTextColor: headerTextColor,
|
|
96
|
+
freezedTextColor: freezedTextColor,
|
|
97
|
+
sortState: sortState,
|
|
98
|
+
});
|
|
99
|
+
return (react_1.default.createElement("div", { style: {
|
|
100
|
+
borderRadius: "10px 0 0 10px",
|
|
101
|
+
borderWidth: "0px 0px 0px 5px",
|
|
102
|
+
borderColor: (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[500],
|
|
103
|
+
boxShadow: theme.shadows.lg,
|
|
104
|
+
} },
|
|
105
|
+
react_1.default.createElement(ka_table_1.Table, { columns: columns, data: sortedData, rowKeyField: rowKey, editingMode: Edit, key: columns, sortingMode: TableEnums.SortingMode.MultipleRemote, format: format,
|
|
106
|
+
// paging={paging}
|
|
107
|
+
filteringMode: undefined, childComponents: mergedChildComponents, columnReordering: columnReorder, columnResizing: columnResizing, editableCells: editableCells, validation: validation, loading: loading, virtualScrolling: {
|
|
108
|
+
enabled: true,
|
|
109
|
+
} })));
|
|
75
110
|
};
|
|
76
111
|
exports.default = react_1.default.memo(KaTable);
|
|
@@ -14,9 +14,10 @@ export type KaTableProps = {
|
|
|
14
14
|
checkSelect?: any;
|
|
15
15
|
onRowClick?: (rowData: any, column: any) => void;
|
|
16
16
|
onSelectionChange?: (selectedIds: any[]) => void;
|
|
17
|
-
onSortChange?: (newSortState: string, columnName: string) => void;
|
|
18
|
-
onMenuItemClick?: (action: string, columnName: string) => void;
|
|
19
|
-
menuItems?: any;
|
|
20
17
|
selected?: any;
|
|
21
18
|
columnVisibility?: boolean;
|
|
19
|
+
headerBgColor?: string;
|
|
20
|
+
headerTextColor?: string;
|
|
21
|
+
freezedBgColor?: string;
|
|
22
|
+
freezedTextColor?: string;
|
|
22
23
|
};
|
|
@@ -40,8 +40,10 @@ var SelectionHeader = function (_a) {
|
|
|
40
40
|
return (react_1.default.createElement("input", { ref: selectAllRef, type: "checkbox", checked: selected === null || selected === void 0 ? void 0 : selected.checked, onChange: function (event) {
|
|
41
41
|
var _a, _b;
|
|
42
42
|
var isChecked = event.currentTarget.checked;
|
|
43
|
-
|
|
44
|
-
var totalIds = isChecked
|
|
43
|
+
// const action = isChecked ? "add" : "remove";
|
|
44
|
+
var totalIds = isChecked
|
|
45
|
+
? (_b = (_a = table === null || table === void 0 ? void 0 : table.props) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map(function (row) { return row[rowKey]; })
|
|
46
|
+
: [];
|
|
45
47
|
handleSelectionChange(totalIds);
|
|
46
48
|
if (isChecked) {
|
|
47
49
|
table.selectAllFilteredRows();
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
.ka {
|
|
2
|
-
border-radius: 10px 0 0 10px;
|
|
3
|
-
border-width: 0px 0px 0px 5px;
|
|
4
|
-
border-color: #2caa3d;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.ka-thead-cell {
|
|
1
|
+
.ka-thead-cell {
|
|
8
2
|
padding: 7px 7px;
|
|
9
3
|
}
|
|
10
4
|
.ka-cell {
|
|
@@ -20,7 +14,7 @@
|
|
|
20
14
|
overflow: hidden;
|
|
21
15
|
text-overflow: ellipsis;
|
|
22
16
|
white-space: nowrap;
|
|
23
|
-
padding-left:5%;
|
|
17
|
+
padding-left: 5%;
|
|
24
18
|
}
|
|
25
19
|
.ka-row {
|
|
26
20
|
box-sizing: unset;
|
|
@@ -30,4 +24,4 @@
|
|
|
30
24
|
.ka-table-wrapper {
|
|
31
25
|
border-bottom: 2px solid #d8d9db;
|
|
32
26
|
border-right: 2px solid #d8d9db;
|
|
33
|
-
}
|
|
27
|
+
}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { KaTableProps } from "./KaTableProps";
|
|
2
|
+
type MergedChildComponentsProps = Pick<KaTableProps, "headerBgColor" | "headerTextColor" | "freezedBgColor" | "freezedTextColor"> & {
|
|
3
|
+
childComponents: any;
|
|
4
|
+
onSortChange: any;
|
|
5
|
+
handleSelection: any;
|
|
6
|
+
rowKey: any;
|
|
7
|
+
onRowClick: any;
|
|
8
|
+
selected: any;
|
|
9
|
+
dataLength: number;
|
|
10
|
+
columns: any;
|
|
11
|
+
sortState: any;
|
|
12
|
+
};
|
|
13
|
+
declare const useMergedChildComponents: ({ childComponents, onSortChange, handleSelection, rowKey, onRowClick, selected, dataLength, columns, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, sortState, }: MergedChildComponentsProps) => any;
|
|
2
14
|
export default useMergedChildComponents;
|
|
@@ -51,19 +51,31 @@ var CustomHeader_1 = __importDefault(require("./CustomHeader"));
|
|
|
51
51
|
var SelectionHeader_1 = __importDefault(require("./SelectionHeader"));
|
|
52
52
|
var SelectionCell_1 = __importDefault(require("./SelectionCell"));
|
|
53
53
|
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
var table_1 = require("../../Utils/table");
|
|
55
|
+
var useMergedChildComponents = function (_a) {
|
|
56
|
+
var childComponents = _a.childComponents, onSortChange = _a.onSortChange, handleSelection = _a.handleSelection, rowKey = _a.rowKey, onRowClick = _a.onRowClick, selected = _a.selected, dataLength = _a.dataLength, columns = _a.columns, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, sortState = _a.sortState;
|
|
57
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
58
|
+
var handleSortChange = (0, react_1.useCallback)(function (newState, columnKey) {
|
|
59
|
+
var newSortState = __spreadArray([], sortState, true);
|
|
60
|
+
var existingIndex = newSortState.findIndex(function (sort) { return sort.column === columnKey; });
|
|
61
|
+
if (existingIndex === -1) {
|
|
62
|
+
newSortState.push({
|
|
63
|
+
column: columnKey,
|
|
64
|
+
direction: newState, // Default to ascending when adding a column
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var existingSort = newSortState[existingIndex];
|
|
69
|
+
existingSort.direction = newState;
|
|
70
|
+
}
|
|
71
|
+
var column = columns.find(function (col) { return col.key === columnKey; });
|
|
72
|
+
column.sortDirection = newState;
|
|
73
|
+
onSortChange(newSortState);
|
|
74
|
+
}, [sortState, onSortChange, columns]);
|
|
75
|
+
var _b = react_1.default.useState(selected), selections = _b[0], setSelections = _b[1];
|
|
63
76
|
(0, react_1.useEffect)(function () {
|
|
64
77
|
setSelections(selected);
|
|
65
78
|
}, [selected]);
|
|
66
|
-
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
67
79
|
var isAllSelected = (0, react_1.useMemo)(function () {
|
|
68
80
|
return {
|
|
69
81
|
checked: (selections === null || selections === void 0 ? void 0 : selections.length) === (dataLength || -1),
|
|
@@ -90,7 +102,7 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
90
102
|
return (0, react_1.useMemo)(function () {
|
|
91
103
|
return __assign(__assign({}, childComponents), { dataRow: {
|
|
92
104
|
elementAttributes: function (props) {
|
|
93
|
-
var _a;
|
|
105
|
+
var _a, _b;
|
|
94
106
|
var existingElementAttributes = (_a = childComponents.dataRow) === null || _a === void 0 ? void 0 : _a.elementAttributes;
|
|
95
107
|
var attributes = existingElementAttributes
|
|
96
108
|
? existingElementAttributes(props)
|
|
@@ -101,11 +113,11 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
101
113
|
// `${attributes.className || ""} ${isSelected ? "ka-row-selected" : ""}`.trim();
|
|
102
114
|
return __assign(__assign({}, attributes), { className: className, style: __assign(__assign({}, (attributes.style || {})), { backgroundColor: isSelected
|
|
103
115
|
? theme.colors.backgroundColor.subtle
|
|
104
|
-
: undefined }) });
|
|
116
|
+
: undefined, border: "1px solid ".concat((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[200]) }) });
|
|
105
117
|
},
|
|
106
118
|
}, headCell: {
|
|
107
119
|
content: function (props) {
|
|
108
|
-
var _a;
|
|
120
|
+
var _a, _b, _c;
|
|
109
121
|
var existingContent = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.content;
|
|
110
122
|
if (existingContent) {
|
|
111
123
|
var result = existingContent(props);
|
|
@@ -113,16 +125,17 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
113
125
|
return result;
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return (react_1.default.createElement(CustomHeader_1.default, __assign({}, props, { onSortChange:
|
|
128
|
+
var column = props.column;
|
|
129
|
+
if (column.sortable || column.filter) {
|
|
130
|
+
return (react_1.default.createElement(CustomHeader_1.default, __assign({}, props, { onSortChange: handleSortChange, menuItems: (_b = column === null || column === void 0 ? void 0 : column.menu) !== null && _b !== void 0 ? _b : [], isSort: props.column.sortable, sortDirection: (_c = props.column.sortDirection) !== null && _c !== void 0 ? _c : "none" })));
|
|
119
131
|
}
|
|
120
132
|
if (props.column.key === "select-cell") {
|
|
121
133
|
return (react_1.default.createElement(SelectionHeader_1.default, { onSelectionChange: headerSelectionHandle, rowKey: rowKey, selected: isAllSelected }));
|
|
122
134
|
}
|
|
135
|
+
return null;
|
|
123
136
|
},
|
|
124
137
|
elementAttributes: function (props) {
|
|
125
|
-
var _a;
|
|
138
|
+
var _a, _b, _c, _d, _e, _f;
|
|
126
139
|
var existingElementAttributes = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
|
|
127
140
|
if (existingElementAttributes) {
|
|
128
141
|
var result = existingElementAttributes(props);
|
|
@@ -131,15 +144,22 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
131
144
|
}
|
|
132
145
|
}
|
|
133
146
|
if (props.column.columnFreeze) {
|
|
134
|
-
var stickyLeft = getPreviousColumnWidth(columns, props.column.key);
|
|
147
|
+
var stickyLeft = (0, table_1.getPreviousColumnWidth)(columns, props.column.key);
|
|
135
148
|
return {
|
|
136
|
-
style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 3, backgroundColor:
|
|
149
|
+
style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 3, backgroundColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.backgroundColor.subtle, color: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600] }),
|
|
137
150
|
};
|
|
138
151
|
}
|
|
152
|
+
return {
|
|
153
|
+
style: {
|
|
154
|
+
backgroundColor: headerBgColor !== null && headerBgColor !== void 0 ? headerBgColor : (_d = theme.colors.backgroundColor) === null || _d === void 0 ? void 0 : _d.subtle,
|
|
155
|
+
color: headerTextColor !== null && headerTextColor !== void 0 ? headerTextColor : (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.gray[600],
|
|
156
|
+
border: "1px solid ".concat((_f = theme.colors) === null || _f === void 0 ? void 0 : _f.gray[200]),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
139
159
|
},
|
|
140
160
|
}, cell: {
|
|
141
161
|
elementAttributes: function (props) {
|
|
142
|
-
var _a;
|
|
162
|
+
var _a, _b, _c, _d, _e;
|
|
143
163
|
var existingElementAttributes = (_a = childComponents.cell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
|
|
144
164
|
if (existingElementAttributes) {
|
|
145
165
|
var result = existingElementAttributes(props);
|
|
@@ -148,12 +168,17 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
148
168
|
}
|
|
149
169
|
}
|
|
150
170
|
if (props.column.columnFreeze) {
|
|
151
|
-
var stickyLeft = getPreviousColumnWidth(columns, props.column.key);
|
|
171
|
+
var stickyLeft = (0, table_1.getPreviousColumnWidth)(columns, props.column.key);
|
|
152
172
|
return {
|
|
153
|
-
style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 2, backgroundColor:
|
|
173
|
+
style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 2, backgroundColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.backgroundColor.subtle, color: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600], fontWeight: 600 }),
|
|
154
174
|
};
|
|
155
175
|
}
|
|
156
176
|
return {
|
|
177
|
+
style: {
|
|
178
|
+
color: (_d = theme.colors) === null || _d === void 0 ? void 0 : _d.gray[600],
|
|
179
|
+
fontWeight: 500,
|
|
180
|
+
border: "1px solid ".concat((_e = theme.colors) === null || _e === void 0 ? void 0 : _e.gray[200]),
|
|
181
|
+
},
|
|
157
182
|
onClick: function () {
|
|
158
183
|
if (onRowClick) {
|
|
159
184
|
onRowClick(props.rowData, props.column.key);
|
|
@@ -174,7 +199,6 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
174
199
|
}
|
|
175
200
|
}
|
|
176
201
|
if (props.column.key === "select-cell") {
|
|
177
|
-
// console.log("CELLL", selections, props.rowData[rowKey]);
|
|
178
202
|
var isSelected = selections === null || selections === void 0 ? void 0 : selections.includes(props.rowData[rowKey]);
|
|
179
203
|
return (react_1.default.createElement(SelectionCell_1.default, __assign({}, props, { selected: isSelected, onSelectionChange: cellSelectionHandle })));
|
|
180
204
|
}
|
|
@@ -182,18 +206,19 @@ var useMergedChildComponents = function (childComponents, onSortChange, onMenuIt
|
|
|
182
206
|
} });
|
|
183
207
|
}, [
|
|
184
208
|
childComponents,
|
|
185
|
-
onSortChange,
|
|
186
|
-
onMenuItemClick,
|
|
187
|
-
menuItems,
|
|
188
209
|
rowKey,
|
|
189
210
|
onRowClick,
|
|
190
211
|
selections,
|
|
191
|
-
columnVisibility,
|
|
192
212
|
columns,
|
|
193
213
|
cellSelectionHandle,
|
|
194
214
|
headerSelectionHandle,
|
|
195
215
|
isAllSelected,
|
|
196
|
-
theme.colors
|
|
216
|
+
theme.colors,
|
|
217
|
+
headerBgColor,
|
|
218
|
+
headerTextColor,
|
|
219
|
+
freezedBgColor,
|
|
220
|
+
freezedTextColor,
|
|
221
|
+
handleSortChange,
|
|
197
222
|
]);
|
|
198
223
|
};
|
|
199
224
|
exports.default = useMergedChildComponents;
|