pixelize-design-library 1.1.60 → 1.1.62
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/Table/Components/TableBody.js +13 -28
- package/dist/Components/Table/Components/TableHeader.js +1 -1
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Table/Table.js +8 -8
- package/dist/Components/Table/TableProps.d.ts +1 -0
- package/dist/Utils/table.d.ts +19 -1
- package/dist/Utils/table.js +32 -1
- package/package.json +1 -1
|
@@ -104,35 +104,20 @@ var TableBody = function (_a) {
|
|
|
104
104
|
isContent && (react_2.default.createElement(RenderContent, { rowIndex: rowIndex, isExpanded: isExpanded, isContent: !!row.content })),
|
|
105
105
|
isCheckbox && react_2.default.createElement(RenderCheckbox, { row: row, isChecked: isChecked }),
|
|
106
106
|
columns.map(function (header, headerIndex) {
|
|
107
|
-
var _a, _b
|
|
107
|
+
var _a, _b;
|
|
108
108
|
if (header.isHidden)
|
|
109
109
|
return null;
|
|
110
110
|
var isFrozen = header.isFreeze;
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(_g = (_f = (_e = row.cellStyle) === null || _e === void 0 ? void 0 : _e[header.id]) === null || _f === void 0 ? void 0 : _f.color) !== null && _g !== void 0 ? _g : undefined;
|
|
122
|
-
}
|
|
123
|
-
else if (isFrozen) {
|
|
124
|
-
cellBgColor = freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : undefined;
|
|
125
|
-
cellTextColor = freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : undefined;
|
|
126
|
-
}
|
|
127
|
-
else if (index % 2 === 1) {
|
|
128
|
-
cellBgColor = theme.colors.backgroundColor.light;
|
|
129
|
-
}
|
|
130
|
-
var rowBgColor = undefined;
|
|
131
|
-
var rowTextColor = undefined;
|
|
132
|
-
if (row.rowStyle) {
|
|
133
|
-
rowBgColor = (_h = row.rowStyle) === null || _h === void 0 ? void 0 : _h.bg;
|
|
134
|
-
rowTextColor = (_j = row.rowStyle) === null || _j === void 0 ? void 0 : _j.color;
|
|
135
|
-
}
|
|
111
|
+
var _c = (0, table_1.TableCellCalculation)({
|
|
112
|
+
isFrozen: isFrozen,
|
|
113
|
+
columnWidths: columnWidths,
|
|
114
|
+
headerIndex: headerIndex,
|
|
115
|
+
isCheckbox: isCheckbox,
|
|
116
|
+
header: header,
|
|
117
|
+
row: row,
|
|
118
|
+
freezedBgColor: freezedBgColor,
|
|
119
|
+
index: index,
|
|
120
|
+
}), leftOffset = _c.leftOffset, cellBgColor = _c.cellBgColor, rowBgColor = _c.rowBgColor, cellTextColor = _c.cellTextColor, rowTextColor = _c.rowTextColor;
|
|
136
121
|
return (react_2.default.createElement(react_1.Td, { maxWidth: 500, minWidth: 120, key: headerIndex + 1, onClick: function () {
|
|
137
122
|
return !header.node
|
|
138
123
|
? handleRowClick(row, {
|
|
@@ -142,12 +127,12 @@ var TableBody = function (_a) {
|
|
|
142
127
|
: null;
|
|
143
128
|
}, fontSize: 14, fontWeight: 400, position: isFrozen ? "sticky" : undefined, left: isFrozen ? leftOffset : undefined, zIndex: isFrozen ? 1 : 0, backgroundColor: cellBgColor !== null && cellBgColor !== void 0 ? cellBgColor : rowBgColor, textOverflow: "ellipsis", border: noBorders
|
|
144
129
|
? "none"
|
|
145
|
-
: "1px solid ".concat((
|
|
130
|
+
: "1px solid ".concat((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.gray[isFrozen || isChecked ? 300 : 200]), className: "columns ".concat(isFrozen ? "sticky-columns" : "scrollable-columns"), boxSizing: "border-box", color: cellTextColor !== null && cellTextColor !== void 0 ? cellTextColor : rowTextColor, _hover: ((_b = row.cellStyle) === null || _b === void 0 ? void 0 : _b[header.id]) || row.rowStyle
|
|
146
131
|
? {}
|
|
147
132
|
: {
|
|
148
133
|
backgroundColor: theme.colors.gray[100],
|
|
149
134
|
} },
|
|
150
|
-
react_2.default.createElement(react_1.Box, {
|
|
135
|
+
react_2.default.createElement(react_1.Box, { display: "block", overflow: "hidden", whiteSpace: "normal", overflowWrap: "break-word" }, header.node ? header.node(row) : row[header.id])));
|
|
151
136
|
}),
|
|
152
137
|
isLink && react_2.default.createElement(RenderView, { row: row, bgcolor: freezeViewColor })),
|
|
153
138
|
row.content && isExpanded && (react_2.default.createElement(react_1.Tr, null,
|
|
@@ -51,7 +51,7 @@ var TableHeader = function (_a) {
|
|
|
51
51
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
52
52
|
var RenderCheckbox = (0, react_2.useCallback)(function () {
|
|
53
53
|
var _a;
|
|
54
|
-
return (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((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.gray[300]), position: "sticky", className: "columns sticky-columns", left: "0px", zIndex: 9, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)"
|
|
54
|
+
return (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((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.gray[300]), position: "sticky", className: "columns sticky-columns", left: "0px", zIndex: 9, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)" },
|
|
55
55
|
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: "outline", onChange: function () { return handleCheckbox(0); }, isChecked: isLoading ? false : checked === true, isIndeterminate: checked === "indeterminate", _hover: { transform: "scale(1.1)" } })));
|
|
56
56
|
}, [
|
|
57
57
|
checked,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableProps } from "./TableProps";
|
|
3
3
|
import "./Table.css";
|
|
4
|
-
export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferencesUrl, preferencesKey, preferencesName, preferencesPage, authToken, paginationMode, noOfRowsPerPage, totalRecords, onPagination, }: TableProps): React.JSX.Element;
|
|
4
|
+
export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferencesUrl, preferencesKey, preferencesName, preferencesPage, authToken, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, }: TableProps): React.JSX.Element;
|
|
@@ -40,17 +40,17 @@ var usePreferences_1 = require("../../Hooks/usePreferences");
|
|
|
40
40
|
var TableSettings_1 = __importDefault(require("./TableSettings/TableSettings"));
|
|
41
41
|
function Table(_a) {
|
|
42
42
|
var _b, _c, _d;
|
|
43
|
-
var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _e = _a.isCheckbox, isCheckbox = _e === void 0 ? false : _e, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _f = _a.noBorders, noBorders = _f === void 0 ? false : _f, _g = _a.isPagination, isPagination = _g === void 0 ? true : _g, onRowClick = _a.onRowClick, selections = _a.selections, _h = _a.isActionFreeze, isActionFreeze = _h === void 0 ? true : _h, _j = _a.preferencesUrl, preferencesUrl = _j === void 0 ? "" : _j, _k = _a.preferencesKey, preferencesKey = _k === void 0 ? "" : _k, _l = _a.preferencesName, preferencesName = _l === void 0 ? "" : _l, _m = _a.preferencesPage, preferencesPage = _m === void 0 ? "" : _m, _o = _a.authToken, authToken = _o === void 0 ? "" : _o, _p = _a.paginationMode, paginationMode = _p === void 0 ? "client" : _p, _q = _a.noOfRowsPerPage, noOfRowsPerPage = _q === void 0 ? 50 : _q, _r = _a.totalRecords, totalRecords = _r === void 0 ? 0 : _r, onPagination = _a.onPagination;
|
|
43
|
+
var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _e = _a.isCheckbox, isCheckbox = _e === void 0 ? false : _e, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _f = _a.noBorders, noBorders = _f === void 0 ? false : _f, _g = _a.isPagination, isPagination = _g === void 0 ? true : _g, onRowClick = _a.onRowClick, selections = _a.selections, _h = _a.isActionFreeze, isActionFreeze = _h === void 0 ? true : _h, _j = _a.preferencesUrl, preferencesUrl = _j === void 0 ? "" : _j, _k = _a.preferencesKey, preferencesKey = _k === void 0 ? "" : _k, _l = _a.preferencesName, preferencesName = _l === void 0 ? "" : _l, _m = _a.preferencesPage, preferencesPage = _m === void 0 ? "" : _m, _o = _a.authToken, authToken = _o === void 0 ? "" : _o, _p = _a.paginationMode, paginationMode = _p === void 0 ? "client" : _p, _q = _a.noOfRowsPerPage, noOfRowsPerPage = _q === void 0 ? 50 : _q, _r = _a.totalRecords, totalRecords = _r === void 0 ? 0 : _r, onPagination = _a.onPagination, _s = _a.isTableSettings, isTableSettings = _s === void 0 ? false : _s;
|
|
44
44
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
45
|
-
var
|
|
45
|
+
var _t = (0, react_1.useState)({}), columnsSearch = _t[0], setColumnsSearch = _t[1];
|
|
46
46
|
var isServerPagination = paginationMode === "server";
|
|
47
|
-
var
|
|
47
|
+
var _u = (0, usePreferences_1.useGetPreferences)({
|
|
48
48
|
baseUrl: preferencesUrl,
|
|
49
49
|
page: preferencesPage,
|
|
50
50
|
key: preferencesKey,
|
|
51
51
|
name: preferencesName,
|
|
52
52
|
authToken: authToken,
|
|
53
|
-
}), preferences =
|
|
53
|
+
}), preferences = _u.preferences, loading = _u.loading;
|
|
54
54
|
var savePreferences = (0, usePreferences_1.useSavePreferences)({
|
|
55
55
|
baseUrl: preferencesUrl,
|
|
56
56
|
page: preferencesPage,
|
|
@@ -67,7 +67,7 @@ function Table(_a) {
|
|
|
67
67
|
}
|
|
68
68
|
return {};
|
|
69
69
|
}, [preferences]);
|
|
70
|
-
var
|
|
70
|
+
var _v = (0, useTable_1.default)({
|
|
71
71
|
tableBorderColor: tableBorderColor,
|
|
72
72
|
data: data,
|
|
73
73
|
isPagination: isPagination,
|
|
@@ -79,7 +79,7 @@ function Table(_a) {
|
|
|
79
79
|
noOfRowsPerPage: noOfRowsPerPage,
|
|
80
80
|
totalRecords: totalRecords,
|
|
81
81
|
isServerPagination: isServerPagination,
|
|
82
|
-
}), tableData =
|
|
82
|
+
}), tableData = _v.tableData, tableContainerStyles = _v.tableContainerStyles, isContent = _v.isContent, isLink = _v.isLink, headerRefs = _v.headerRefs, columnWidths = _v.columnWidths, handleSort = _v.handleSort, handleCheckbox = _v.handleCheckbox, filteredData = _v.filteredData, startRow = _v.startRow, endRow = _v.endRow, selection = _v.selection, columnsSort = _v.columnsSort, currentPage = _v.currentPage, pages = _v.pages, rowsPerPage = _v.rowsPerPage, handlePageSizeChange = _v.handlePageSizeChange, setCurrentPage = _v.setCurrentPage, columnsList = _v.columnsList, handleColumnPreferences = _v.handleColumnPreferences;
|
|
83
83
|
var _filteredData = (0, react_1.useMemo)(function () {
|
|
84
84
|
return (0, table_1.searchAndSortData)(filteredData, columnsSearch);
|
|
85
85
|
}, [columnsSearch, filteredData]);
|
|
@@ -89,10 +89,10 @@ function Table(_a) {
|
|
|
89
89
|
}
|
|
90
90
|
}, [currentPage, onPagination, noOfRowsPerPage]);
|
|
91
91
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
92
|
-
react_1.default.createElement(TableSettings_1.default, { columns: columnsList, onSave: function (cols) { return handleColumnPreferences(cols); } }),
|
|
92
|
+
isTableSettings && (react_1.default.createElement(TableSettings_1.default, { columns: columnsList, onSave: function (cols) { return handleColumnPreferences(cols); } })),
|
|
93
93
|
react_1.default.createElement(react_2.TableContainer, { sx: tableContainerStyles },
|
|
94
94
|
react_1.default.createElement(react_3.Table, { variant: "simple", size: "sm", overflowX: "scroll", minW: "100%", className: "table_wrapper" },
|
|
95
|
-
react_1.default.createElement(react_3.Thead, { position: "sticky", top: 0, zIndex: 2 },
|
|
95
|
+
react_1.default.createElement(react_3.Thead, { position: "sticky", top: -0.5, zIndex: 2 },
|
|
96
96
|
react_1.default.createElement(TableHeader_1.default, { columns: columnsList, 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], handleSort: handleSort, headerRefs: headerRefs, columnWidths: columnWidths, columnsSort: columnsSort, noBorders: noBorders, handleCheckbox: handleCheckbox, isLoading: isTableLoading, checked: tableData.length !== 0 && selection.length === tableData.length
|
|
97
97
|
? true
|
|
98
98
|
: selection.length === 0
|
package/dist/Utils/table.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KaTableProps } from "../Components/KaTable/KaTableProps";
|
|
2
|
-
import { DataObject } from "../Components/Table/TableProps";
|
|
2
|
+
import { DataObject, TableHeaderProps } from "../Components/Table/TableProps";
|
|
3
3
|
export declare function SortMultiColumnData(data: Record<string, string | number>[], sortConfig: {
|
|
4
4
|
column: string | number;
|
|
5
5
|
direction: string;
|
|
@@ -10,3 +10,21 @@ export declare const calculateLeftOffset: (columns: number[], index: number) =>
|
|
|
10
10
|
export declare const searchAndSortData: (data: DataObject[], searchValues: Record<string, string>) => DataObject[];
|
|
11
11
|
export declare function debounce<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
|
|
12
12
|
export declare const pageSizeCalculation: (records: number) => number[];
|
|
13
|
+
type TableCellCalculationProps = {
|
|
14
|
+
isFrozen?: boolean;
|
|
15
|
+
columnWidths: number[];
|
|
16
|
+
headerIndex: number;
|
|
17
|
+
isCheckbox?: boolean;
|
|
18
|
+
header: TableHeaderProps;
|
|
19
|
+
row: DataObject;
|
|
20
|
+
freezedBgColor?: string;
|
|
21
|
+
index: number;
|
|
22
|
+
};
|
|
23
|
+
export declare const TableCellCalculation: ({ isFrozen, columnWidths, headerIndex, isCheckbox, header, row, freezedBgColor, index, }: TableCellCalculationProps) => {
|
|
24
|
+
leftOffset: number;
|
|
25
|
+
cellBgColor: any;
|
|
26
|
+
rowBgColor: any;
|
|
27
|
+
cellTextColor: any;
|
|
28
|
+
rowTextColor: any;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
package/dist/Utils/table.js
CHANGED
|
@@ -9,7 +9,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.pageSizeCalculation = exports.debounce = exports.searchAndSortData = exports.calculateLeftOffset = exports.getFieldType = exports.getPreviousColumnWidth = exports.SortMultiColumnData = void 0;
|
|
12
|
+
exports.TableCellCalculation = exports.pageSizeCalculation = exports.debounce = exports.searchAndSortData = exports.calculateLeftOffset = exports.getFieldType = exports.getPreviousColumnWidth = exports.SortMultiColumnData = void 0;
|
|
13
|
+
var useCustomTheme_1 = require("../Theme/useCustomTheme");
|
|
13
14
|
function SortMultiColumnData(data, sortConfig) {
|
|
14
15
|
if (!sortConfig.length)
|
|
15
16
|
return data;
|
|
@@ -107,3 +108,33 @@ var pageSizeCalculation = function (records) {
|
|
|
107
108
|
return pageSize;
|
|
108
109
|
};
|
|
109
110
|
exports.pageSizeCalculation = pageSizeCalculation;
|
|
111
|
+
var TableCellCalculation = function (_a) {
|
|
112
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
113
|
+
var isFrozen = _a.isFrozen, columnWidths = _a.columnWidths, headerIndex = _a.headerIndex, isCheckbox = _a.isCheckbox, header = _a.header, row = _a.row, freezedBgColor = _a.freezedBgColor, index = _a.index;
|
|
114
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
115
|
+
var leftOffset = isFrozen
|
|
116
|
+
? (0, exports.calculateLeftOffset)(columnWidths, headerIndex) + (isCheckbox ? 50 : 0)
|
|
117
|
+
: 0;
|
|
118
|
+
var cellBgColor = undefined;
|
|
119
|
+
var cellTextColor = undefined;
|
|
120
|
+
if ((_b = row.cellStyle) === null || _b === void 0 ? void 0 : _b[header.id]) {
|
|
121
|
+
cellBgColor =
|
|
122
|
+
(_e = (_d = (_c = row.cellStyle) === null || _c === void 0 ? void 0 : _c[header.id]) === null || _d === void 0 ? void 0 : _d.bg) !== null && _e !== void 0 ? _e : theme.colors.backgroundColor.light;
|
|
123
|
+
cellTextColor = (_h = (_g = (_f = row.cellStyle) === null || _f === void 0 ? void 0 : _f[header.id]) === null || _g === void 0 ? void 0 : _g.color) !== null && _h !== void 0 ? _h : undefined;
|
|
124
|
+
}
|
|
125
|
+
else if (isFrozen) {
|
|
126
|
+
cellBgColor = freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : undefined;
|
|
127
|
+
cellTextColor = freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : undefined;
|
|
128
|
+
}
|
|
129
|
+
else if (index % 2 === 1) {
|
|
130
|
+
cellBgColor = theme.colors.backgroundColor.light;
|
|
131
|
+
}
|
|
132
|
+
var rowBgColor = undefined;
|
|
133
|
+
var rowTextColor = undefined;
|
|
134
|
+
if (row.rowStyle) {
|
|
135
|
+
rowBgColor = (_j = row.rowStyle) === null || _j === void 0 ? void 0 : _j.bg;
|
|
136
|
+
rowTextColor = (_k = row.rowStyle) === null || _k === void 0 ? void 0 : _k.color;
|
|
137
|
+
}
|
|
138
|
+
return { leftOffset: leftOffset, cellBgColor: cellBgColor, rowBgColor: rowBgColor, cellTextColor: cellTextColor, rowTextColor: rowTextColor };
|
|
139
|
+
};
|
|
140
|
+
exports.TableCellCalculation = TableCellCalculation;
|