pixelize-design-library 2.2.107 → 2.2.109
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/Pagination.d.ts +2 -1
- package/dist/Components/Table/Components/Pagination.js +8 -4
- package/dist/Components/Table/Components/useTable.d.ts +2 -1
- package/dist/Components/Table/Components/useTable.js +4 -1
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Table/Table.js +10 -3
- package/dist/Components/Table/TableProps.d.ts +5 -0
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ type PaginationProps = Pick<TableProps, "isVisiblity" | "columns"> & {
|
|
|
9
9
|
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
|
|
10
10
|
dataLength: number;
|
|
11
11
|
isServerPagination: boolean;
|
|
12
|
+
pageSizeOptions?: (number | string)[];
|
|
12
13
|
};
|
|
13
|
-
declare const Pagination: ({ paginationText, handlePageSizeChange, rowsPerPage, currentPage, pages, setCurrentPage, dataLength, isServerPagination, }: PaginationProps) => React.JSX.Element;
|
|
14
|
+
declare const Pagination: ({ paginationText, handlePageSizeChange, rowsPerPage, currentPage, pages, setCurrentPage, dataLength, isServerPagination, pageSizeOptions, }: PaginationProps) => React.JSX.Element;
|
|
14
15
|
export default Pagination;
|
|
@@ -8,16 +8,20 @@ var react_2 = require("@chakra-ui/react");
|
|
|
8
8
|
var table_1 = require("../../../Utils/table");
|
|
9
9
|
var lucide_react_1 = require("lucide-react");
|
|
10
10
|
var Pagination = function (_a) {
|
|
11
|
-
var paginationText = _a.paginationText, handlePageSizeChange = _a.handlePageSizeChange, rowsPerPage = _a.rowsPerPage, currentPage = _a.currentPage, pages = _a.pages, setCurrentPage = _a.setCurrentPage, dataLength = _a.dataLength, isServerPagination = _a.isServerPagination;
|
|
12
|
-
var
|
|
11
|
+
var paginationText = _a.paginationText, handlePageSizeChange = _a.handlePageSizeChange, rowsPerPage = _a.rowsPerPage, currentPage = _a.currentPage, pages = _a.pages, setCurrentPage = _a.setCurrentPage, dataLength = _a.dataLength, isServerPagination = _a.isServerPagination, pageSizeOptions = _a.pageSizeOptions;
|
|
12
|
+
var computedOptions = pageSizeOptions && pageSizeOptions.length
|
|
13
|
+
? pageSizeOptions
|
|
14
|
+
: (0, table_1.pageSizeCalculation)(dataLength);
|
|
13
15
|
// const isLeftDisabled = currentPage === 0;
|
|
14
16
|
// const isRightDisabled = currentPage >= pages - 1;
|
|
15
17
|
var isLeftDisabled = dataLength === 0 || currentPage === 0;
|
|
16
18
|
var isRightDisabled = dataLength === 0 || currentPage >= pages - 1;
|
|
17
19
|
return (react_1.default.createElement(react_2.Flex, { justify: "flex-end", align: "center" },
|
|
18
20
|
!isServerPagination && (react_1.default.createElement(react_2.Select, { onChange: handlePageSizeChange, value: rowsPerPage, size: "xs", borderRadius: 3, width: 20, isDisabled: dataLength === 0 },
|
|
19
|
-
dataLength < 100 ? react_1.default.createElement("option", { value: 0 }) : null,
|
|
20
|
-
|
|
21
|
+
!pageSizeOptions && dataLength < 100 ? react_1.default.createElement("option", { value: 0 }) : null,
|
|
22
|
+
computedOptions.map(function (size, index) {
|
|
23
|
+
return (react_1.default.createElement("option", { key: index, value: size }, String(size)));
|
|
24
|
+
}))),
|
|
21
25
|
dataLength > 0 && (react_1.default.createElement(react_2.Flex, null,
|
|
22
26
|
react_1.default.createElement(react_2.IconButton, { "aria-label": "first-page", color: isLeftDisabled ? "gray" : "black", rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: function () { return setCurrentPage(0); } },
|
|
23
27
|
react_1.default.createElement(lucide_react_1.ChevronsLeft, null)),
|
|
@@ -12,8 +12,9 @@ type UseTableProps = {
|
|
|
12
12
|
noOfRowsPerPage?: number;
|
|
13
13
|
isServerPagination: boolean;
|
|
14
14
|
totalRecords: number;
|
|
15
|
+
onNoOfRowsPerPageChange?: (noOfRows: number) => void;
|
|
15
16
|
};
|
|
16
|
-
declare const useTable: ({ tableBorderColor, data, isPagination, selections, onSelection, tablePreferences, savePreferences, noOfRowsPerPage, isServerPagination, totalRecords, columns, }: UseTableProps) => {
|
|
17
|
+
declare const useTable: ({ tableBorderColor, data, isPagination, selections, onSelection, tablePreferences, savePreferences, noOfRowsPerPage, isServerPagination, totalRecords, columns, onNoOfRowsPerPageChange, }: UseTableProps) => {
|
|
17
18
|
tableData: DataObject[];
|
|
18
19
|
tableContainerStyles: {
|
|
19
20
|
borderRadius: string;
|
|
@@ -25,7 +25,7 @@ var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
|
25
25
|
var table_1 = require("../../../Utils/table");
|
|
26
26
|
var defaultPageSize = 50;
|
|
27
27
|
var useTable = function (_a) {
|
|
28
|
-
var tableBorderColor = _a.tableBorderColor, data = _a.data, isPagination = _a.isPagination, selections = _a.selections, onSelection = _a.onSelection, tablePreferences = _a.tablePreferences, savePreferences = _a.savePreferences, noOfRowsPerPage = _a.noOfRowsPerPage, isServerPagination = _a.isServerPagination, totalRecords = _a.totalRecords, columns = _a.columns;
|
|
28
|
+
var tableBorderColor = _a.tableBorderColor, data = _a.data, isPagination = _a.isPagination, selections = _a.selections, onSelection = _a.onSelection, tablePreferences = _a.tablePreferences, savePreferences = _a.savePreferences, noOfRowsPerPage = _a.noOfRowsPerPage, isServerPagination = _a.isServerPagination, totalRecords = _a.totalRecords, columns = _a.columns, onNoOfRowsPerPageChange = _a.onNoOfRowsPerPageChange;
|
|
29
29
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
30
30
|
var headerRefs = (0, react_1.useRef)([]);
|
|
31
31
|
var _b = (0, react_1.useState)([]), columnWidths = _b[0], setColumnWidths = _b[1];
|
|
@@ -90,6 +90,9 @@ var useTable = function (_a) {
|
|
|
90
90
|
var handlePageSizeChange = function (event) {
|
|
91
91
|
var value = Number(event.target.value);
|
|
92
92
|
setRowsPerPage(value !== 0 ? value : defaultPageSize);
|
|
93
|
+
if (onNoOfRowsPerPageChange) {
|
|
94
|
+
onNoOfRowsPerPageChange(value !== 0 ? value : defaultPageSize);
|
|
95
|
+
}
|
|
93
96
|
setCurrentPage(0);
|
|
94
97
|
};
|
|
95
98
|
var handleSort = (0, react_1.useCallback)(function (field, sort) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableProps } from "./TableProps";
|
|
3
|
-
export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferences, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, headerActions, onGlobalSearch, tableSettings, filterSidebar }: TableProps): React.JSX.Element;
|
|
3
|
+
export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferences, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, headerActions, onGlobalSearch, onNoOfRowsPerPageChange, paginationSelectOptions, tableMaxHeight, minVisibleRows, maxVisibleRows, tableSettings, filterSidebar }: TableProps): React.JSX.Element;
|
|
@@ -54,7 +54,7 @@ function Table(_a) {
|
|
|
54
54
|
name: "",
|
|
55
55
|
page: "",
|
|
56
56
|
orgId: "",
|
|
57
|
-
} : _u, _v = _a.paginationMode, paginationMode = _v === void 0 ? "client" : _v, _w = _a.noOfRowsPerPage, noOfRowsPerPage = _w === void 0 ? 50 : _w, _x = _a.totalRecords, totalRecords = _x === void 0 ? 0 : _x, onPagination = _a.onPagination, _y = _a.isTableSettings, isTableSettings = _y === void 0 ? false : _y, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch, tableSettings = _a.tableSettings, filterSidebar = _a.filterSidebar
|
|
57
|
+
} : _u, _v = _a.paginationMode, paginationMode = _v === void 0 ? "client" : _v, _w = _a.noOfRowsPerPage, noOfRowsPerPage = _w === void 0 ? 50 : _w, _x = _a.totalRecords, totalRecords = _x === void 0 ? 0 : _x, onPagination = _a.onPagination, _y = _a.isTableSettings, isTableSettings = _y === void 0 ? false : _y, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch, onNoOfRowsPerPageChange = _a.onNoOfRowsPerPageChange, paginationSelectOptions = _a.paginationSelectOptions, tableMaxHeight = _a.tableMaxHeight, minVisibleRows = _a.minVisibleRows, maxVisibleRows = _a.maxVisibleRows, tableSettings = _a.tableSettings, filterSidebar = _a.filterSidebar
|
|
58
58
|
// onColumnFilter
|
|
59
59
|
;
|
|
60
60
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
@@ -97,6 +97,7 @@ function Table(_a) {
|
|
|
97
97
|
noOfRowsPerPage: noOfRowsPerPage,
|
|
98
98
|
totalRecords: totalRecords,
|
|
99
99
|
isServerPagination: isServerPagination,
|
|
100
|
+
onNoOfRowsPerPageChange: onNoOfRowsPerPageChange,
|
|
100
101
|
}), tableData = _1.tableData, isContent = _1.isContent, isLink = _1.isLink, headerRefs = _1.headerRefs, columnWidths = _1.columnWidths, handleSort = _1.handleSort, handleCheckbox = _1.handleCheckbox, filteredData = _1.filteredData, startRow = _1.startRow, endRow = _1.endRow, selection = _1.selection, columnsSort = _1.columnsSort, currentPage = _1.currentPage, pages = _1.pages, rowsPerPage = _1.rowsPerPage, handlePageSizeChange = _1.handlePageSizeChange, setCurrentPage = _1.setCurrentPage, columnsList = _1.columnsList, handleColumnPreferences = _1.handleColumnPreferences;
|
|
101
102
|
var _filteredData = (0, react_1.useMemo)(function () {
|
|
102
103
|
return (0, table_1.searchAndSortData)(filteredData, columnsSearch);
|
|
@@ -108,7 +109,13 @@ function Table(_a) {
|
|
|
108
109
|
}, [currentPage, onPagination, noOfRowsPerPage]);
|
|
109
110
|
var tablePaginationText = "".concat(startRow + 1, " - ").concat(endRow > tableData.length ? tableData.length : endRow, " of ").concat(isServerPagination ? totalRecords : tableData.length);
|
|
110
111
|
var controlsHeight = 45;
|
|
111
|
-
var
|
|
112
|
+
var estimatedRowHeight = 45;
|
|
113
|
+
var actualRows = _filteredData.length;
|
|
114
|
+
var minRows = typeof minVisibleRows === "number" ? Math.max(0, minVisibleRows) : 5;
|
|
115
|
+
var maxRows = typeof maxVisibleRows === "number" ? Math.max(minRows, maxVisibleRows) : 10;
|
|
116
|
+
var visibleRowsCount = Math.max(minRows, Math.min(actualRows, maxRows));
|
|
117
|
+
var dynamicMaxH = Math.min(500, (visibleRowsCount * estimatedRowHeight) + estimatedRowHeight);
|
|
118
|
+
var tableMaxH = typeof tableMaxHeight === "number" ? tableMaxHeight : dynamicMaxH;
|
|
112
119
|
return (react_1.default.createElement(react_2.Box, { bg: (_c = (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.background) === null || _c === void 0 ? void 0 : _c[50], border: "0.063rem solid ".concat((_d = theme.colors.border) === null || _d === void 0 ? void 0 : _d[500]), borderRadius: 3 },
|
|
113
120
|
react_1.default.createElement(react_2.Flex, { align: "start" },
|
|
114
121
|
react_1.default.createElement(MotionBox, { initial: { width: 0 }, animate: { width: (filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.isFilterSidebar) ? 180 : 0 }, transition: { type: "tween", duration: 0.25 }, overflow: "hidden", flexShrink: 0, borderRight: "1px solid", borderColor: (_e = theme.colors.border) === null || _e === void 0 ? void 0 : _e[500], style: { height: controlsHeight + tableMaxH } },
|
|
@@ -127,7 +134,7 @@ function Table(_a) {
|
|
|
127
134
|
react_1.default.createElement(HeaderActions_1.default, { actions: headerActions, selections: selection }))) : null,
|
|
128
135
|
react_1.default.createElement(ActiveFilters_1.default, { columns: columnsList, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch }),
|
|
129
136
|
(isPagination || isServerPagination) && (react_1.default.createElement(react_2.Box, { ml: "auto", minW: 310 },
|
|
130
|
-
react_1.default.createElement(Pagination_1.default, { columns: columns, currentPage: currentPage, setCurrentPage: setCurrentPage, rowsPerPage: rowsPerPage, pages: pages, paginationText: tablePaginationText, handlePageSizeChange: handlePageSizeChange, dataLength: tableData.length, isServerPagination: isServerPagination, isVisiblity: true })))),
|
|
137
|
+
react_1.default.createElement(Pagination_1.default, { columns: columns, currentPage: currentPage, setCurrentPage: setCurrentPage, rowsPerPage: rowsPerPage, pages: pages, paginationText: tablePaginationText, handlePageSizeChange: handlePageSizeChange, dataLength: tableData.length, isServerPagination: isServerPagination, pageSizeOptions: paginationSelectOptions, isVisiblity: true })))),
|
|
131
138
|
react_1.default.createElement(react_2.TableContainer, { position: "relative", maxH: tableMaxH, overflowY: "auto", overflowX: "auto", sx: {
|
|
132
139
|
'&::-webkit-scrollbar': {
|
|
133
140
|
width: '6px',
|
|
@@ -24,6 +24,11 @@ export type TableProps = {
|
|
|
24
24
|
noOfRowsPerPage?: number;
|
|
25
25
|
totalRecords?: number;
|
|
26
26
|
onPagination?: (page: number, noOfRecords: number) => void;
|
|
27
|
+
onNoOfRowsPerPageChange?: (noOfRows: number) => void;
|
|
28
|
+
paginationSelectOptions?: (number | string)[];
|
|
29
|
+
tableMaxHeight?: number;
|
|
30
|
+
minVisibleRows?: number;
|
|
31
|
+
maxVisibleRows?: number;
|
|
27
32
|
headerActions?: HeaderActionsProps;
|
|
28
33
|
onGlobalSearch?: (searchVal: string) => void;
|
|
29
34
|
onColumnFilter?: (filters: Record<string, any>) => void;
|