pixelize-design-library 1.1.38 → 1.1.41
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/DatePicker/DatePicker.js +1 -1
- package/dist/Components/ProfileCard/ProfileCard.d.ts +1 -1
- package/dist/Components/ProfileCard/ProfileCard.js +5 -3
- package/dist/Components/ProfileCard/ProfileCardProps.d.ts +1 -0
- package/dist/Components/SelectSearch/SelectSearch.js +0 -3
- package/dist/Components/SideBar/SideBar.js +4 -4
- package/dist/Components/Table/Components/Pagination.d.ts +1 -1
- package/dist/Components/Table/Components/TableBody.d.ts +1 -1
- package/dist/Components/Table/Components/TableBody.js +100 -34
- package/dist/Components/Table/Components/TableHeader.d.ts +1 -1
- package/dist/Components/Table/Components/TableHeader.js +28 -4
- package/dist/Components/Table/Table.js +4 -2
- package/dist/Components/Table/TableProps.d.ts +10 -6
- package/dist/Pages/datePick.d.ts +1 -1
- package/dist/Pages/table.js +10 -1
- package/dist/Utils/table.d.ts +1 -1
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ function DatePicker(_a) {
|
|
|
32
32
|
? dateTimeFormat
|
|
33
33
|
? dateTimeFormat
|
|
34
34
|
: "MM/dd/yyyy h:mm aa"
|
|
35
|
-
: dateFormat, showTimeSelect: showTimeSelect, timeFormat: timeFormat, timeIntervals: timeIntervals, timeCaption: timeCaption, id: id, name: name, customInput: react_1.default.createElement(react_2.Input, { size: "sm", bg: theme.colors.backgroundColor.light, style: { border: error ? "
|
|
35
|
+
: dateFormat, showTimeSelect: showTimeSelect, timeFormat: timeFormat, timeIntervals: timeIntervals, timeCaption: timeCaption, id: id, name: name, customInput: react_1.default.createElement(react_2.Input, { size: "sm", bg: theme.colors.backgroundColor.light, style: { border: error ? "2px solid #DC143C" : "" } }) })),
|
|
36
36
|
error && react_1.default.createElement(ErrorMessage_1.default, { errorMessage: errorMessage }),
|
|
37
37
|
helperText && !error && react_1.default.createElement(HelperText_1.default, { helperText: helperText })));
|
|
38
38
|
}
|
|
@@ -9,4 +9,4 @@ export declare const ProfileCardBody: React.FC<{
|
|
|
9
9
|
export declare const ProfileCardFooter: React.FC<{
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
}>;
|
|
12
|
-
export default function ProfileCard({ maxW, align, variant, direction, justify, children, size, color, overflow, dividercolor, dividersize, dividervariant, CardStyle, borderTopColor, borderLeftColor, }: ProfileCardProps): React.JSX.Element;
|
|
12
|
+
export default function ProfileCard({ maxW, align, variant, direction, justify, children, size, color, overflow, dividercolor, dividersize, dividervariant, CardStyle, CardHeaderStyle, borderTopColor, borderLeftColor, }: ProfileCardProps): React.JSX.Element;
|
|
@@ -33,17 +33,19 @@ var ProfileCardFooter = function (_a) {
|
|
|
33
33
|
};
|
|
34
34
|
exports.ProfileCardFooter = ProfileCardFooter;
|
|
35
35
|
function ProfileCard(_a) {
|
|
36
|
-
var maxW = _a.maxW, align = _a.align, variant = _a.variant, direction = _a.direction, justify = _a.justify, children = _a.children, size = _a.size, color = _a.color, overflow = _a.overflow, _b = _a.dividercolor, dividercolor = _b === void 0 ? "#d5cfcf" : _b, _c = _a.dividersize, dividersize = _c === void 0 ? "0.5px" : _c, _d = _a.dividervariant, dividervariant = _d === void 0 ? "solid" : _d, CardStyle = _a.CardStyle, borderTopColor = _a.borderTopColor, borderLeftColor = _a.borderLeftColor;
|
|
36
|
+
var maxW = _a.maxW, align = _a.align, variant = _a.variant, direction = _a.direction, justify = _a.justify, children = _a.children, size = _a.size, color = _a.color, overflow = _a.overflow, _b = _a.dividercolor, dividercolor = _b === void 0 ? "#d5cfcf" : _b, _c = _a.dividersize, dividersize = _c === void 0 ? "0.5px" : _c, _d = _a.dividervariant, dividervariant = _d === void 0 ? "solid" : _d, CardStyle = _a.CardStyle, CardHeaderStyle = _a.CardHeaderStyle, borderTopColor = _a.borderTopColor, borderLeftColor = _a.borderLeftColor;
|
|
37
37
|
var isReactElement = function (child) {
|
|
38
38
|
return child !== null && typeof child === "object" && "type" in child;
|
|
39
39
|
};
|
|
40
40
|
var header = react_1.default.Children.toArray(children).find(function (child) { return isReactElement(child) && child.type === exports.ProfileCardHeader; });
|
|
41
41
|
var body = react_1.default.Children.toArray(children).find(function (child) { return isReactElement(child) && child.type === exports.ProfileCardBody; });
|
|
42
42
|
var footer = react_1.default.Children.toArray(children).find(function (child) { return isReactElement(child) && child.type === exports.ProfileCardFooter; });
|
|
43
|
-
var StylesWithBorder = borderLeftColor
|
|
43
|
+
var StylesWithBorder = borderLeftColor
|
|
44
|
+
? __assign(__assign({}, CardStyle), { borderLeft: "2px solid #3182CE" }) : borderTopColor
|
|
45
|
+
? __assign(__assign({}, CardStyle), { borderTop: "2px solid #3182CE" }) : __assign({}, CardStyle);
|
|
44
46
|
return (react_1.default.createElement(react_2.Card, { maxW: maxW, align: align, variant: variant, direction: direction, justify: justify, size: size, overflow: overflow, colorScheme: color, style: StylesWithBorder },
|
|
45
47
|
header && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
-
react_1.default.createElement(react_2.CardHeader, {
|
|
48
|
+
react_1.default.createElement(react_2.CardHeader, { sx: __assign(__assign({}, CardHeaderStyle), { fontWeight: "bold" }) }, header),
|
|
47
49
|
react_1.default.createElement(react_2.Divider, { style: {
|
|
48
50
|
borderColor: dividercolor,
|
|
49
51
|
borderWidth: dividersize,
|
|
@@ -9,6 +9,7 @@ export type ProfileCardProps = Pick<CardProps, "direction" | "maxW" | "align" |
|
|
|
9
9
|
dividersize?: string;
|
|
10
10
|
dividervariant?: "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "inset" | "outset";
|
|
11
11
|
CardStyle?: React.CSSProperties;
|
|
12
|
+
CardHeaderStyle?: React.CSSProperties;
|
|
12
13
|
borderTopColor?: boolean;
|
|
13
14
|
borderLeftColor?: boolean;
|
|
14
15
|
};
|
|
@@ -324,9 +324,6 @@ function SelectSearch(_a) {
|
|
|
324
324
|
var filteredOptions = (0, react_1.useMemo)(function () {
|
|
325
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()); });
|
|
326
326
|
}, [options, inputValue]);
|
|
327
|
-
(0, react_1.useEffect)(function () {
|
|
328
|
-
setInputValue(searchQuery);
|
|
329
|
-
}, [searchQuery]);
|
|
330
327
|
// const handleOptionClick = useCallback(
|
|
331
328
|
// (option: selectOptions) => {
|
|
332
329
|
// if (isMultipleSelect) {
|
|
@@ -38,7 +38,7 @@ function Sidebar(_a) {
|
|
|
38
38
|
return (react_1.default.createElement(react_2.Menu, { key: menu.title, placement: "right" },
|
|
39
39
|
react_1.default.createElement(react_2.Link, { backgroundColor: activeMenu === menu.title && !toggle
|
|
40
40
|
? theme.colors.primary[500]
|
|
41
|
-
: "none",
|
|
41
|
+
: "none", paddingLeft: toggle ? "" : "20px",
|
|
42
42
|
// borderRadius={8}
|
|
43
43
|
_hover: {
|
|
44
44
|
textDecor: "none",
|
|
@@ -58,15 +58,15 @@ function Sidebar(_a) {
|
|
|
58
58
|
menu.subMenu.map(function (subMenuItem) { return (react_1.default.createElement(react_2.MenuItem, { key: subMenuItem.title }, subMenuItem.title)); })))));
|
|
59
59
|
})));
|
|
60
60
|
}, [activeMenu, menus, handleMenuClick, toggle, theme.colors]);
|
|
61
|
-
return (react_1.default.createElement(react_2.Flex, { pos: "sticky", h: "100vh", boxShadow: theme.shadows.lg, w: toggle ? "75px" : "200px", flexDir: "column", justifyContent: "space-between", background: theme.colors.backgroundColor.light },
|
|
61
|
+
return (react_1.default.createElement(react_2.Flex, { transition: "all 0.5s", pos: "sticky", h: "100vh", boxShadow: theme.shadows.lg, w: toggle ? "75px" : "200px", flexDir: "column", justifyContent: "space-between", background: theme.colors.backgroundColor.light },
|
|
62
62
|
react_1.default.createElement(react_2.Flex, { flexDir: "column", w: "100%", alignItems: "center", as: "nav", h: "100vh" },
|
|
63
63
|
logo ? (react_1.default.createElement(react_2.Flex, { mt: 5, alignItems: "center", gap: 5 },
|
|
64
64
|
react_1.default.createElement(react_2.Image, { borderRadius: "full", boxSize: "45px", src: logo, alt: "Company Logo" }),
|
|
65
65
|
react_1.default.createElement(react_2.Text, { display: toggle ? "none" : "flex", fontSize: 20, fontWeight: 800 }, companyName))) : (react_1.default.createElement(react_2.Box, { ml: "-8px", mt: 5, width: "100%", display: "flex", justifyContent: "center", alignItems: "center" },
|
|
66
66
|
react_1.default.createElement(react_2.Text, { fontWeight: 800, fontSize: "1.3rem", textAlign: "center" }, toggle ? companyName[0] : companyName))),
|
|
67
|
-
react_1.default.createElement(react_2.Flex, { position: "absolute", left: toggle ? "55px" : "180px", top: "60px", background: theme.colors.primary[500], borderRadius: "23px" },
|
|
67
|
+
react_1.default.createElement(react_2.Flex, { transition: "all 0.5s", position: "absolute", left: toggle ? "55px" : "180px", top: "60px", background: theme.colors.primary[500], borderRadius: "23px" },
|
|
68
68
|
react_1.default.createElement(react_2.IconButton, { background: "none", icon: toggle ? (react_1.default.createElement(fi_1.FiChevronRight, { color: (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.white })) : (react_1.default.createElement(fi_1.FiChevronLeft, { color: (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.white })), _hover: { background: "none" }, onClick: changeToggle, "aria-label": "Toggle Navigation" })),
|
|
69
|
-
react_1.default.createElement(react_2.Flex, { mt:
|
|
69
|
+
react_1.default.createElement(react_2.Flex, { mt: 50, flexDir: "column", w: "100%", alignItems: toggle ? "center" : "flex-start", h: "100vh", overflow: "auto", css: Sidebar_1.FlexCss },
|
|
70
70
|
react_1.default.createElement(RenderMenuItems, null)))));
|
|
71
71
|
}
|
|
72
72
|
exports.default = Sidebar;
|
|
@@ -7,7 +7,7 @@ type PaginationProps = Pick<TableProps, "isVisiblity" | "columns"> & {
|
|
|
7
7
|
rowsPerPage: number;
|
|
8
8
|
currentPage: number;
|
|
9
9
|
pages: number;
|
|
10
|
-
handleColumnVisibilityChange: (header: string) => void;
|
|
10
|
+
handleColumnVisibilityChange: (header: string | number) => void;
|
|
11
11
|
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
|
|
12
12
|
dataLength: number;
|
|
13
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
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;
|
|
3
|
+
declare const TableBody: ({ data, isCheckbox, columns, visibleColumns, startRow, endRow, columnWidths, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, selections, isLoading, onRowClick, isContent, isLink, }: TableBodyPageProps) => React.JSX.Element;
|
|
4
4
|
export default TableBody;
|
|
@@ -1,19 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
var react_1 = require("@chakra-ui/react");
|
|
7
|
-
var react_2 =
|
|
27
|
+
var react_2 = __importStar(require("react"));
|
|
8
28
|
var table_1 = require("../../../Utils/table");
|
|
9
29
|
var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
10
30
|
var TableLoading_1 = require("./TableLoading");
|
|
31
|
+
var fa_1 = require("react-icons/fa");
|
|
32
|
+
var icons_1 = require("@chakra-ui/icons");
|
|
11
33
|
var TableBody = function (_a) {
|
|
12
|
-
var
|
|
34
|
+
var _b;
|
|
35
|
+
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, isContent = _a.isContent, isLink = _a.isLink;
|
|
13
36
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
37
|
+
var _c = (0, react_2.useState)(new Set()), expandedRows = _c[0], setExpandedRows = _c[1];
|
|
38
|
+
var toggleRowExpansion = function (rowIndex) {
|
|
39
|
+
setExpandedRows(function (prev) {
|
|
40
|
+
var newSet = new Set(prev);
|
|
41
|
+
if (newSet.has(rowIndex)) {
|
|
42
|
+
newSet.delete(rowIndex);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
newSet.add(rowIndex);
|
|
46
|
+
}
|
|
47
|
+
return newSet;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
14
50
|
var handleRowClick = function (row, header) {
|
|
15
51
|
onRowClick && onRowClick(row, header);
|
|
16
52
|
};
|
|
53
|
+
var RenderCheckbox = (0, react_2.useCallback)(function (_a) {
|
|
54
|
+
var _b;
|
|
55
|
+
var row = _a.row;
|
|
56
|
+
return (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((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[300]), boxSizing: "border-box", left: 0, zIndex: 1, className: "columns sticky-columns" },
|
|
57
|
+
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) })));
|
|
58
|
+
}, [
|
|
59
|
+
freezedBgColor,
|
|
60
|
+
freezedTextColor,
|
|
61
|
+
handleCheckbox,
|
|
62
|
+
noBorders,
|
|
63
|
+
selections,
|
|
64
|
+
(_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray,
|
|
65
|
+
]);
|
|
66
|
+
var RenderContent = (0, react_2.useCallback)(function (_a) {
|
|
67
|
+
var _b, _c;
|
|
68
|
+
var isExpanded = _a.isExpanded, rowIndex = _a.rowIndex, isContent = _a.isContent;
|
|
69
|
+
return (react_2.default.createElement(react_1.Td, { w: "6", p: 0, fontSize: 14, backgroundColor: freezedBgColor, color: freezedTextColor, position: "sticky", border: noBorders ? "none" : "1px solid ".concat((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[300]), boxSizing: "border-box", left: 0, zIndex: 1, className: "columns sticky-columns" }, isContent && (react_2.default.createElement(react_1.IconButton, { "aria-label": isExpanded ? "Collapse row" : "Expand row", color: (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600], icon: isExpanded ? (react_2.default.createElement(fa_1.FaAngleDown, { fontSize: 16 })) : (react_2.default.createElement(fa_1.FaAngleRight, { fontSize: 16 })), size: "sm", onClick: function () { return toggleRowExpansion(rowIndex); }, variant: "ghost" }))));
|
|
70
|
+
}, [freezedBgColor, freezedTextColor, noBorders, theme.colors.gray]);
|
|
71
|
+
var RenderView = (0, react_2.useCallback)(function (_a) {
|
|
72
|
+
var _b, _c;
|
|
73
|
+
var row = _a.row;
|
|
74
|
+
return (react_2.default.createElement(react_1.Td, { w: 2, p: 0, fontSize: 14, backgroundColor: freezedBgColor, color: freezedTextColor, position: "sticky", border: noBorders ? "none" : "1px solid ".concat((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[300]), boxSizing: "border-box", right: 0, zIndex: 1, className: "columns sticky-columns" }, !!row.onLink && (react_2.default.createElement(react_1.IconButton, { "aria-label": "Link", color: (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600], icon: react_2.default.createElement(icons_1.ExternalLinkIcon, { fontSize: 16 }), size: "sm", onClick: function () { return row === null || row === void 0 ? void 0 : row.onLink(row); }, variant: "ghost" }))));
|
|
75
|
+
}, [freezedBgColor, freezedTextColor, noBorders, theme.colors.gray]);
|
|
17
76
|
if (isLoading) {
|
|
18
77
|
var totalVisibleColumns = Object.values(visibleColumns).filter(Boolean).length +
|
|
19
78
|
(isCheckbox ? 1 : 0);
|
|
@@ -28,36 +87,43 @@ var TableBody = function (_a) {
|
|
|
28
87
|
react_2.default.createElement("p", null, "No data found")))));
|
|
29
88
|
}
|
|
30
89
|
return (react_2.default.createElement(react_2.default.Fragment, null, data.slice(startRow, endRow).map(function (row, index) {
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
:
|
|
56
|
-
?
|
|
57
|
-
:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
var rowIndex = startRow + index;
|
|
91
|
+
var isExpanded = expandedRows.has(rowIndex);
|
|
92
|
+
return (react_2.default.createElement(react_2.default.Fragment, { key: rowIndex },
|
|
93
|
+
react_2.default.createElement(react_1.Tr, { key: index + 1, _hover: {
|
|
94
|
+
"& > td": {
|
|
95
|
+
backgroundColor: theme.colors.gray[100],
|
|
96
|
+
},
|
|
97
|
+
} },
|
|
98
|
+
isContent && (react_2.default.createElement(RenderContent, { rowIndex: rowIndex, isExpanded: isExpanded, isContent: !!row.content })),
|
|
99
|
+
isCheckbox && react_2.default.createElement(RenderCheckbox, { row: row }),
|
|
100
|
+
columns.map(function (header, headerIndex) {
|
|
101
|
+
var _a;
|
|
102
|
+
var isFrozen = header.isFreeze;
|
|
103
|
+
var leftOffset = isFrozen
|
|
104
|
+
? (0, table_1.calculateLeftOffset)(columnWidths, headerIndex) +
|
|
105
|
+
(isCheckbox ? 50 : 0)
|
|
106
|
+
: 0;
|
|
107
|
+
return (visibleColumns[header.label] && (react_2.default.createElement(react_1.Td, { maxWidth: 500, minWidth: 120, key: headerIndex + 1, onClick: function () {
|
|
108
|
+
return !header.node
|
|
109
|
+
? handleRowClick(row, {
|
|
110
|
+
label: header.label,
|
|
111
|
+
id: header.id,
|
|
112
|
+
})
|
|
113
|
+
: null;
|
|
114
|
+
}, fontSize: 14, fontWeight: 400, position: isFrozen ? "sticky" : undefined, left: isFrozen ? leftOffset : undefined, zIndex: isFrozen ? 1 : 0, backgroundColor: isFrozen
|
|
115
|
+
? freezedBgColor
|
|
116
|
+
: index % 2 === 1
|
|
117
|
+
? theme.colors.backgroundColor.light
|
|
118
|
+
: "white", textOverflow: "ellipsis", border: noBorders
|
|
119
|
+
? "none"
|
|
120
|
+
: "1px solid ".concat((_a = theme.colors) === null || _a === void 0 ? void 0 : _a.gray[isFrozen ? 300 : 200]), className: "columns ".concat(isFrozen ? "sticky-columns" : "scrollable-columns"), boxSizing: "border-box", color: isFrozen ? freezedTextColor : undefined },
|
|
121
|
+
react_2.default.createElement(react_1.Box, { textOverflow: "ellipsis", whiteSpace: "nowrap", display: "block", overflow: "hidden" }, header.node ? header.node(row) : row[header.id]))));
|
|
122
|
+
}),
|
|
123
|
+
isLink && react_2.default.createElement(RenderView, { row: row })),
|
|
124
|
+
row.content && isExpanded && (react_2.default.createElement(react_1.Tr, null,
|
|
125
|
+
react_2.default.createElement(react_1.Td, { colSpan: columns.length + (isCheckbox ? 1 : 0) + (isContent ? 1 : 0), p: 2 },
|
|
126
|
+
react_2.default.createElement(react_1.Box, { p: 2, bg: theme.colors.white, borderRadius: "md" }, row === null || row === void 0 ? void 0 : row.content(row)))))));
|
|
61
127
|
})));
|
|
62
128
|
};
|
|
63
129
|
exports.default = TableBody;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
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;
|
|
3
|
+
declare const TableHeader: ({ columns, isCheckbox, visibleColumns, handleSort, headerRefs, columnWidths, columnsSort, headerBgColor, headerTextColor, freezedBgColor, freezedTextColor, noBorders, handleCheckbox, checked, isLoading, isContent, isLink, }: TableHeaderPageProps) => React.JSX.Element;
|
|
4
4
|
export default TableHeader;
|
|
@@ -30,11 +30,34 @@ 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, 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;
|
|
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, isContent = _a.isContent, isLink = _a.isLink;
|
|
34
34
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
35
|
+
var RenderCheckbox = (0, react_2.useCallback)(function () {
|
|
36
|
+
var _a;
|
|
37
|
+
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: 1, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)" },
|
|
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(0); }, isChecked: isLoading ? false : checked === true, isIndeterminate: checked === "indeterminate" })));
|
|
39
|
+
}, [
|
|
40
|
+
checked,
|
|
41
|
+
freezedBgColor,
|
|
42
|
+
freezedTextColor,
|
|
43
|
+
handleCheckbox,
|
|
44
|
+
isLoading,
|
|
45
|
+
noBorders,
|
|
46
|
+
(_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray,
|
|
47
|
+
]);
|
|
48
|
+
var RenderConent = (0, react_2.useCallback)(function () {
|
|
49
|
+
var _a;
|
|
50
|
+
return (react_2.default.createElement(react_1.Th, { w: "6", p: 0, 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: 1, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)" },
|
|
51
|
+
react_2.default.createElement(react_1.Box, { display: "flex", justifyContent: "center" },
|
|
52
|
+
react_2.default.createElement(fa_1.FaExpandArrowsAlt, { fontSize: 14 }))));
|
|
53
|
+
}, [freezedBgColor, noBorders, theme.colors.gray]);
|
|
54
|
+
var RenderView = (0, react_2.useCallback)(function () {
|
|
55
|
+
var _a;
|
|
56
|
+
return (react_2.default.createElement(react_1.Th, { w: "6", p: 0, 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", right: "0px", zIndex: 1, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)" }));
|
|
57
|
+
}, [freezedBgColor, noBorders, theme.colors.gray]);
|
|
35
58
|
return (react_2.default.createElement(react_1.Tr, null,
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
isContent && react_2.default.createElement(RenderConent, null),
|
|
60
|
+
isCheckbox && react_2.default.createElement(RenderCheckbox, null),
|
|
38
61
|
columns.map(function (header, index) {
|
|
39
62
|
var _a, _b;
|
|
40
63
|
var isFrozen = header.isFreeze;
|
|
@@ -59,7 +82,8 @@ var TableHeader = function (_a) {
|
|
|
59
82
|
}
|
|
60
83
|
handleSort(header.id, direction);
|
|
61
84
|
} })))))));
|
|
62
|
-
})
|
|
85
|
+
}),
|
|
86
|
+
isLink && react_2.default.createElement(RenderView, null)));
|
|
63
87
|
};
|
|
64
88
|
exports.default = TableHeader;
|
|
65
89
|
var SortingIcon = (0, react_2.memo)(function (_a) {
|
|
@@ -128,6 +128,8 @@ function Table(_a) {
|
|
|
128
128
|
return (__assign(__assign({}, prev), (_a = {}, _a[header] = !prev[header], _a)));
|
|
129
129
|
});
|
|
130
130
|
};
|
|
131
|
+
var isContent = (0, react_1.useMemo)(function () { return data.some(function (o) { return o.content; }); }, [data]);
|
|
132
|
+
var isLink = (0, react_1.useMemo)(function () { return data.some(function (o) { return o.onLink; }); }, [data]);
|
|
131
133
|
var RenderTable = function (_a) {
|
|
132
134
|
var _b, _c, _d;
|
|
133
135
|
var columns = _a.columns;
|
|
@@ -137,9 +139,9 @@ function Table(_a) {
|
|
|
137
139
|
? true
|
|
138
140
|
: selection.length === 0
|
|
139
141
|
? false
|
|
140
|
-
: "indeterminate" })),
|
|
142
|
+
: "indeterminate", isContent: isContent, isLink: isLink })),
|
|
141
143
|
react_1.default.createElement(react_3.Tbody, null,
|
|
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 }))));
|
|
144
|
+
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, isContent: isContent, isLink: isLink }))));
|
|
143
145
|
};
|
|
144
146
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
145
147
|
react_1.default.createElement(react_2.TableContainer, { sx: {
|
|
@@ -16,14 +16,14 @@ 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
|
+
onRowClick?: (row: DataObject, header: Record<string | number, string | number>) => void;
|
|
20
20
|
};
|
|
21
21
|
export type DataObject = {
|
|
22
|
-
[key: string]: string | number;
|
|
22
|
+
[key: string]: string | number | any;
|
|
23
23
|
};
|
|
24
24
|
export type TableHeaderProps = {
|
|
25
|
-
label: string;
|
|
26
|
-
id: string;
|
|
25
|
+
label: string | number;
|
|
26
|
+
id: string | number;
|
|
27
27
|
isSort?: boolean;
|
|
28
28
|
isSearch?: boolean;
|
|
29
29
|
isFreeze?: boolean;
|
|
@@ -34,12 +34,12 @@ export type ExportOption = {
|
|
|
34
34
|
id: string;
|
|
35
35
|
};
|
|
36
36
|
export type ColumnSortingProps = {
|
|
37
|
-
column: string;
|
|
37
|
+
column: string | number;
|
|
38
38
|
direction: "asc" | "desc" | "none";
|
|
39
39
|
};
|
|
40
40
|
export type TableHeaderPageProps = Pick<TableProps, "columns" | "isCheckbox" | "headerBgColor" | "headerTextColor" | "freezedBgColor" | "freezedTextColor" | "noBorders" | "isLoading"> & {
|
|
41
41
|
visibleColumns: Record<string, boolean>;
|
|
42
|
-
handleSort: (label: string, type: "asc" | "desc" | "none") => void;
|
|
42
|
+
handleSort: (label: string | number, type: "asc" | "desc" | "none") => void;
|
|
43
43
|
activeHeader?: string | null;
|
|
44
44
|
isPopoverOpen?: boolean;
|
|
45
45
|
closePopover?: () => void;
|
|
@@ -50,6 +50,8 @@ export type TableHeaderPageProps = Pick<TableProps, "columns" | "isCheckbox" | "
|
|
|
50
50
|
columnsSort: ColumnSortingProps[];
|
|
51
51
|
handleCheckbox: (selection: string | number) => void;
|
|
52
52
|
checked: boolean | "indeterminate";
|
|
53
|
+
isContent: boolean;
|
|
54
|
+
isLink: boolean;
|
|
53
55
|
};
|
|
54
56
|
export type TableBodyPageProps = Pick<TableProps, "columns" | "isCheckbox" | "data" | "freezedBgColor" | "freezedTextColor" | "noBorders" | "isLoading" | "onRowClick"> & {
|
|
55
57
|
visibleColumns: Record<string, boolean>;
|
|
@@ -58,4 +60,6 @@ export type TableBodyPageProps = Pick<TableProps, "columns" | "isCheckbox" | "da
|
|
|
58
60
|
columnWidths: number[];
|
|
59
61
|
handleCheckbox: (selection: string | number) => void;
|
|
60
62
|
selections: (string | number)[];
|
|
63
|
+
isContent: boolean;
|
|
64
|
+
isLink: boolean;
|
|
61
65
|
};
|
package/dist/Pages/datePick.d.ts
CHANGED
package/dist/Pages/table.js
CHANGED
|
@@ -12,12 +12,21 @@ var tableData = [
|
|
|
12
12
|
name: "John Doe",
|
|
13
13
|
age: 30,
|
|
14
14
|
gender: "Male",
|
|
15
|
+
onLink: function (url) {
|
|
16
|
+
console.log("URL", url);
|
|
17
|
+
},
|
|
15
18
|
},
|
|
16
19
|
{
|
|
17
20
|
id: 2,
|
|
18
21
|
name: "Jane Doe",
|
|
19
22
|
age: 25,
|
|
20
23
|
gender: "Female",
|
|
24
|
+
content: function (data) {
|
|
25
|
+
return (react_1.default.createElement("div", null,
|
|
26
|
+
data.name,
|
|
27
|
+
" - ",
|
|
28
|
+
data.age));
|
|
29
|
+
},
|
|
21
30
|
},
|
|
22
31
|
{
|
|
23
32
|
id: 3,
|
|
@@ -30,7 +39,7 @@ var column = [
|
|
|
30
39
|
{
|
|
31
40
|
label: "Name",
|
|
32
41
|
id: "name",
|
|
33
|
-
isFreeze:
|
|
42
|
+
isFreeze: false,
|
|
34
43
|
isSort: true,
|
|
35
44
|
},
|
|
36
45
|
{
|
package/dist/Utils/table.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KaTableProps } from "../Components/KaTable/KaTableProps";
|
|
2
2
|
import { DataObject } from "../Components/Table/TableProps";
|
|
3
3
|
export declare function SortMultiColumnData(data: Record<string, string | number>[], sortConfig: {
|
|
4
|
-
column: string;
|
|
4
|
+
column: string | number;
|
|
5
5
|
direction: string;
|
|
6
6
|
}[]): Record<string, string | number>[];
|
|
7
7
|
export declare const getPreviousColumnWidth: (columns: KaTableProps["columns"], key: string) => any;
|