pixelize-design-library 1.1.61 → 1.1.63
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/TableActions.js +1 -1
- package/dist/Components/Table/Components/TableBody.js +13 -28
- package/dist/Components/Table/Components/TableHeader.js +1 -1
- package/dist/Components/Table/Table.js +1 -1
- package/dist/Utils/table.d.ts +19 -1
- package/dist/Utils/table.js +32 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var md_1 = require("react-icons/md");
|
|
|
10
10
|
var icons_1 = require("@chakra-ui/icons");
|
|
11
11
|
var TableActions = function (_a) {
|
|
12
12
|
var row = _a.row;
|
|
13
|
-
return (react_1.default.createElement(react_2.Popover, { placement: "bottom-start" },
|
|
13
|
+
return (react_1.default.createElement(react_2.Popover, { placement: "bottom-start", closeOnBlur: true },
|
|
14
14
|
react_1.default.createElement(react_2.PopoverTrigger, null,
|
|
15
15
|
react_1.default.createElement(react_2.IconButton, { "aria-label": "Link", color: "black", icon: react_1.default.createElement(fa_1.FaEllipsisV, { fontSize: 12 }), size: "sm", p: 0, variant: "ghost", _hover: { transform: "scale(1.2)" } })),
|
|
16
16
|
react_1.default.createElement(react_2.Portal, null,
|
|
@@ -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,
|
|
@@ -92,7 +92,7 @@ function Table(_a) {
|
|
|
92
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;
|