pixelize-design-library 2.2.179 → 2.2.182

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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { TableProps } from "../TableProps";
3
- type PaginationProps = Pick<TableProps, "isVisiblity" | "columns"> & {
3
+ type PaginationProps = Pick<TableProps, "isVisiblity" | "columns" | "paginationSelectOptions"> & {
4
4
  paginationText: string;
5
5
  handlePageSizeChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
6
6
  rowsPerPage: number;
@@ -9,7 +9,6 @@ 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)[];
13
12
  };
14
- declare const Pagination: ({ paginationText, handlePageSizeChange, rowsPerPage, currentPage, pages, setCurrentPage, dataLength, isServerPagination, pageSizeOptions, }: PaginationProps) => React.JSX.Element;
13
+ declare const Pagination: ({ paginationText, handlePageSizeChange, rowsPerPage, currentPage, pages, setCurrentPage, dataLength, isServerPagination, paginationSelectOptions, }: PaginationProps) => React.JSX.Element;
15
14
  export default Pagination;
@@ -8,26 +8,24 @@ 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, pageSizeOptions = _a.pageSizeOptions;
12
- var computedOptions = pageSizeOptions && pageSizeOptions.length
13
- ? pageSizeOptions
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, paginationSelectOptions = _a.paginationSelectOptions;
12
+ var computedOptions = paginationSelectOptions && paginationSelectOptions.length
13
+ ? paginationSelectOptions
14
14
  : (0, table_1.pageSizeCalculation)(dataLength);
15
15
  // const isLeftDisabled = currentPage === 0;
16
16
  // const isRightDisabled = currentPage >= pages - 1;
17
17
  var isLeftDisabled = dataLength === 0 || currentPage === 0;
18
18
  var isRightDisabled = dataLength === 0 || currentPage >= pages - 1;
19
19
  return (react_1.default.createElement(react_2.Flex, { justify: "flex-end", align: "center", minW: 0, overflow: "hidden", flexWrap: "nowrap" },
20
- !isServerPagination && (react_1.default.createElement(react_2.Select, { onChange: handlePageSizeChange, value: rowsPerPage, size: "xs", borderRadius: 3, width: 20, isDisabled: dataLength === 0 },
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
- }))),
25
- dataLength > 0 && (react_1.default.createElement(react_2.Flex, null,
20
+ (!isServerPagination || paginationSelectOptions) && (react_1.default.createElement(react_2.Select, { onChange: handlePageSizeChange, value: rowsPerPage, size: "xs", borderRadius: 3, width: 20, isDisabled: dataLength === 0 },
21
+ !paginationSelectOptions && dataLength < 100 ? react_1.default.createElement("option", { value: 0 }) : null,
22
+ computedOptions.map(function (size, index) { return (react_1.default.createElement("option", { key: index, value: size }, String(size))); }))),
23
+ dataLength > 0 && (react_1.default.createElement(react_2.Flex, { w: "100%" },
26
24
  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); } },
27
25
  react_1.default.createElement(lucide_react_1.ChevronsLeft, null)),
28
26
  react_1.default.createElement(react_2.IconButton, { "aria-label": "previous-page", color: isLeftDisabled ? "gray" : "black", rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: function () { return currentPage > 0 && setCurrentPage(currentPage - 1); } },
29
27
  react_1.default.createElement(lucide_react_1.ChevronLeft, null)),
30
- react_1.default.createElement(react_2.Text, { mt: 3, fontSize: 12 }, paginationText),
28
+ react_1.default.createElement(react_2.Text, { mt: 3, fontSize: 12, whiteSpace: "nowrap" }, paginationText),
31
29
  react_1.default.createElement(react_2.IconButton, { "aria-label": "next-page", color: isRightDisabled ? "gray" : "black", rounded: "full", variant: isRightDisabled ? "plain" : "ghost", onClick: function () {
32
30
  return currentPage < pages - 1 && setCurrentPage(currentPage + 1);
33
31
  } },
@@ -94,6 +94,7 @@ var TableBody = function (_a) {
94
94
  react_2.default.createElement("p", null, "No data found")))));
95
95
  }
96
96
  return (react_2.default.createElement(react_2.default.Fragment, null, data.map(function (row, index) {
97
+ var _a;
97
98
  var rowIndex = startRow + index;
98
99
  var isExpanded = expandedRows.has(rowIndex);
99
100
  var isChecked = selections.includes(row.id);
@@ -105,7 +106,7 @@ var TableBody = function (_a) {
105
106
  },
106
107
  }
107
108
  : {} },
108
- isContent && (react_2.default.createElement(RenderContent, { rowIndex: rowIndex, isExpanded: isExpanded, isContent: !!(row === null || row === void 0 ? void 0 : row.content) })),
109
+ isContent && (react_2.default.createElement(RenderContent, { rowIndex: rowIndex, isExpanded: isExpanded, isContent: !!((_a = row === null || row === void 0 ? void 0 : row.content) === null || _a === void 0 ? void 0 : _a.call(row)) })),
109
110
  isCheckbox && react_2.default.createElement(RenderCheckbox, { row: row, isChecked: isChecked }),
110
111
  columns.map(function (header, headerIndex) {
111
112
  var _a, _b, _c, _d, _e, _f, _g;
@@ -121,7 +122,6 @@ var TableBody = function (_a) {
121
122
  row: row,
122
123
  freezedBgColor: freezedBgColor,
123
124
  index: index,
124
- theme: theme,
125
125
  }).leftOffset;
126
126
  return (react_2.default.createElement(react_1.Td, { maxWidth: 500, minWidth: 120, height: 45, key: headerIndex + 1, onClick: function () {
127
127
  return !header.node
@@ -40,7 +40,7 @@ declare const useTable: ({ tableBorderColor, data, isPagination, selections, onS
40
40
  rowsPerPage: number;
41
41
  setCurrentPage: import("react").Dispatch<import("react").SetStateAction<number>>;
42
42
  columnsList: TableHeaderProps[];
43
- handleColumnPreferences: (cols: any) => void;
43
+ handleColumnPreferences: (columns: any) => void;
44
44
  handleGlobalSearch: (query: string) => void;
45
45
  };
46
46
  export default useTable;
@@ -46,18 +46,16 @@ var useTable = function (_a) {
46
46
  var _d = (0, react_1.useState)([]), columnsSort = _d[0], setColumnsSort = _d[1];
47
47
  var _e = (0, react_1.useState)(0), currentPage = _e[0], setCurrentPage = _e[1];
48
48
  var _f = (0, react_1.useState)(noOfRowsPerPage !== null && noOfRowsPerPage !== void 0 ? noOfRowsPerPage : defaultPageSize), rowsPerPage = _f[0], setRowsPerPage = _f[1];
49
- var _g = (0, react_1.useState)(function () {
49
+ (0, react_1.useEffect)(function () {
50
+ if (noOfRowsPerPage !== undefined) {
51
+ setRowsPerPage(noOfRowsPerPage);
52
+ }
53
+ }, [noOfRowsPerPage]);
54
+ var tableData = (0, react_1.useMemo)(function () { return data; }, [data]);
55
+ var _g = (0, react_1.useState)(tableData), filteredData = _g[0], setFilteredData = _g[1];
56
+ var _h = (0, react_1.useState)(function () {
50
57
  return columns.map(function (col) { return (__assign({}, col)); });
51
- }), columnsList = _g[0], setColumnsList = _g[1];
52
- // Stable refs for callbacks that shouldn't appear in deps
53
- var onSelectionRef = (0, react_1.useRef)(onSelection);
54
- onSelectionRef.current = onSelection;
55
- var dataRef = (0, react_1.useRef)(data);
56
- dataRef.current = data;
57
- var tablePreferencesRef = (0, react_1.useRef)(tablePreferences);
58
- tablePreferencesRef.current = tablePreferences;
59
- var savePreferencesRef = (0, react_1.useRef)(savePreferences);
60
- savePreferencesRef.current = savePreferences;
58
+ }), columnsList = _h[0], setColumnsList = _h[1];
61
59
  (0, react_1.useEffect)(function () {
62
60
  var _a;
63
61
  var columnPreference = (_a = tablePreferences === null || tablePreferences === void 0 ? void 0 : tablePreferences.columns) !== null && _a !== void 0 ? _a : [];
@@ -74,6 +72,9 @@ var useTable = function (_a) {
74
72
  setColumnsList(columns.map(function (col) { return (__assign({}, col)); }));
75
73
  }
76
74
  }, [tablePreferences, columns]);
75
+ (0, react_1.useEffect)(function () {
76
+ setFilteredData(tableData);
77
+ }, [tableData]);
77
78
  var tableContainerStyles = (0, react_1.useMemo)(function () {
78
79
  var _a;
79
80
  return ({
@@ -85,99 +86,93 @@ var useTable = function (_a) {
85
86
  overflowY: "auto",
86
87
  });
87
88
  }, [tableBorderColor, theme]);
88
- var isContent = (0, react_1.useMemo)(function () { return data.some(function (o) { return o.content; }); }, [data]);
89
- var isLink = (0, react_1.useMemo)(function () { return data.some(function (o) { return o.onLink || o.onDelete || o.onEdit; }); }, [data]);
89
+ var isContent = (0, react_1.useMemo)(function () { return tableData.some(function (o) { return o.content; }); }, [tableData]);
90
+ var isLink = (0, react_1.useMemo)(function () { return tableData.some(function (o) { return o.onLink || o.onDelete || o.onEdit; }); }, [tableData]);
90
91
  (0, react_1.useEffect)(function () {
91
92
  var widths = headerRefs.current.map(function (ref) { return (ref === null || ref === void 0 ? void 0 : ref.offsetWidth) || 0; });
92
93
  setColumnWidths(widths);
93
94
  }, []);
94
95
  var pages = (0, react_1.useMemo)(function () {
95
96
  if (isServerPagination) {
96
- return Math.ceil(totalRecords / (noOfRowsPerPage !== null && noOfRowsPerPage !== void 0 ? noOfRowsPerPage : 1));
97
+ return Math.ceil(totalRecords / (rowsPerPage || 1));
97
98
  }
98
- return isPagination ? Math.ceil(data.length / rowsPerPage) : 0;
99
+ return isPagination ? Math.ceil(tableData.length / rowsPerPage) : 0;
99
100
  }, [
100
101
  isPagination,
101
102
  rowsPerPage,
102
- data.length,
103
+ tableData.length,
103
104
  totalRecords,
104
105
  isServerPagination,
105
- noOfRowsPerPage,
106
106
  ]);
107
107
  var startRow = (0, react_1.useMemo)(function () { return (!isPagination ? 0 : currentPage * rowsPerPage); }, [currentPage, isPagination, rowsPerPage]);
108
- var endRow = (0, react_1.useMemo)(function () { return (!isPagination ? data.length : startRow + rowsPerPage); }, [isPagination, rowsPerPage, startRow, data.length]);
109
- // Sort once (only re-runs when data or sort config changes, not on page change)
110
- var sortedData = (0, react_1.useMemo)(function () {
111
- if (isServerPagination)
112
- return data;
113
- return (0, table_1.SortMultiColumnData)(data, columnsSort);
114
- }, [data, columnsSort, isServerPagination]);
115
- // Paginate from the already-sorted data
116
- var filteredData = (0, react_1.useMemo)(function () {
117
- if (isServerPagination)
118
- return sortedData;
119
- return sortedData.slice(startRow, endRow);
120
- }, [sortedData, startRow, endRow, isServerPagination]);
121
- var handlePageSizeChange = (0, react_1.useCallback)(function (event) {
108
+ var endRow = (0, react_1.useMemo)(function () { return (!isPagination ? tableData.length : startRow + rowsPerPage); }, [isPagination, rowsPerPage, startRow, tableData.length]);
109
+ (0, react_1.useEffect)(function () {
110
+ if (isServerPagination) {
111
+ return setFilteredData(tableData);
112
+ }
113
+ var sortedData = (0, table_1.SortMultiColumnData)(tableData, columnsSort);
114
+ var data = sortedData.slice(startRow, endRow);
115
+ return setFilteredData(data);
116
+ }, [columnsSort, startRow, endRow, tableData, isServerPagination]);
117
+ var handlePageSizeChange = function (event) {
122
118
  var value = Number(event.target.value);
123
119
  setRowsPerPage(value !== 0 ? value : defaultPageSize);
124
120
  if (onNoOfRowsPerPageChange) {
125
121
  onNoOfRowsPerPageChange(value !== 0 ? value : defaultPageSize);
126
122
  }
127
123
  setCurrentPage(0);
128
- }, [onNoOfRowsPerPageChange]);
129
- // Stable: uses functional updater so columnsSort is not a dependency
124
+ };
130
125
  var handleSort = (0, react_1.useCallback)(function (field, sort) {
131
126
  if (!sort)
132
127
  return;
133
- setColumnsSort(function (prev) {
134
- var next = __spreadArray([], prev, true);
135
- var existingIndex = next.findIndex(function (s) { return s.column === field; });
136
- if (existingIndex === -1) {
137
- next.push({ column: field, direction: "asc" });
138
- }
139
- else {
140
- next[existingIndex] = __assign(__assign({}, next[existingIndex]), { direction: sort });
141
- }
142
- return next;
143
- });
144
- }, []);
128
+ var newSortState = __spreadArray([], columnsSort, true);
129
+ var existingIndex = newSortState.findIndex(function (sort) { return sort.column === field; });
130
+ if (existingIndex === -1) {
131
+ newSortState.push({
132
+ column: field,
133
+ direction: "asc", // Default to ascending when adding a column
134
+ });
135
+ }
136
+ else {
137
+ var existingSort = newSortState[existingIndex];
138
+ existingSort.direction = sort;
139
+ }
140
+ setColumnsSort(newSortState);
141
+ }, [columnsSort]);
145
142
  (0, react_1.useEffect)(function () {
146
143
  setSelection(selections !== null && selections !== void 0 ? selections : []);
147
144
  }, [selections]);
148
- // Stable: uses functional updater + refs so selection/data are not dependencies
149
145
  var handleCheckbox = (0, react_1.useCallback)(function (id) {
150
- setSelection(function (prev) {
151
- var _a;
152
- var currentData = dataRef.current;
153
- var selectedItems;
154
- if (id === 0) {
155
- selectedItems =
156
- prev.length === currentData.length
157
- ? []
158
- : currentData.map(function (item) { return item.id; });
159
- }
160
- else if (prev.includes(id)) {
161
- selectedItems = prev.filter(function (item) { return item !== id; });
146
+ var selectedItems = [];
147
+ if (id === 0) {
148
+ if (selection.length === tableData.length) {
149
+ selectedItems = [];
162
150
  }
163
151
  else {
164
- selectedItems = __spreadArray(__spreadArray([], prev, true), [id], false);
152
+ selectedItems = tableData.map(function (item) { return item.id; });
165
153
  }
166
- (_a = onSelectionRef.current) === null || _a === void 0 ? void 0 : _a.call(onSelectionRef, selectedItems);
167
- return selectedItems;
168
- });
169
- }, []);
170
- var handleColumnPreferences = (0, react_1.useCallback)(function (cols) {
171
- var _a;
172
- setColumnsList(cols);
173
- (_a = savePreferencesRef.current) === null || _a === void 0 ? void 0 : _a.call(savePreferencesRef, __assign(__assign({}, tablePreferencesRef.current), { columns: cols }));
174
- }, []);
175
- var handleGlobalSearch = (0, react_1.useCallback)(function (query) {
176
- // Not used inside Table.tsx render path (Table uses its own _filteredData memo),
177
- // but kept for API compatibility.
178
- }, []);
154
+ }
155
+ else if (selection.includes(id)) {
156
+ selectedItems = selection.filter(function (item) { return item !== id; });
157
+ }
158
+ else {
159
+ selectedItems = __spreadArray(__spreadArray([], selection, true), [id], false);
160
+ }
161
+ setSelection(selectedItems);
162
+ onSelection && onSelection(selectedItems);
163
+ }, [onSelection, selection, tableData]);
164
+ var handleColumnPreferences = function (columns) {
165
+ setColumnsList(columns);
166
+ savePreferences &&
167
+ savePreferences(__assign(__assign({}, tablePreferences), { columns: columns }));
168
+ };
169
+ var handleGlobalSearch = function (query) {
170
+ if (!query)
171
+ setFilteredData(tableData);
172
+ setFilteredData((0, table_1.globalSearchFilter)(tableData, query));
173
+ };
179
174
  return {
180
- tableData: data,
175
+ tableData: tableData,
181
176
  tableContainerStyles: tableContainerStyles,
182
177
  isContent: isContent,
183
178
  isLink: isLink,
@@ -56,17 +56,16 @@ var TableSearch_1 = __importDefault(require("./Components/TableSearch"));
56
56
  var ActiveFilters_1 = __importDefault(require("./Components/ActiveFilters"));
57
57
  var lucide_react_1 = require("lucide-react");
58
58
  var MotionBox = (0, framer_motion_1.motion)(react_2.Box);
59
- var DEFAULT_PREFERENCES = {
60
- url: "",
61
- token: "",
62
- key: "",
63
- name: "",
64
- page: "",
65
- orgId: "",
66
- };
67
59
  function Table(_a) {
68
60
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
69
- var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _0 = _a.isCheckbox, isCheckbox = _0 === void 0 ? false : _0, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _1 = _a.noBorders, noBorders = _1 === void 0 ? false : _1, _2 = _a.isPagination, isPagination = _2 === void 0 ? true : _2, onRowClick = _a.onRowClick, selections = _a.selections, _3 = _a.isActionFreeze, isActionFreeze = _3 === void 0 ? true : _3, _4 = _a.preferences, preferences = _4 === void 0 ? DEFAULT_PREFERENCES : _4, _5 = _a.paginationMode, paginationMode = _5 === void 0 ? "client" : _5, _6 = _a.noOfRowsPerPage, noOfRowsPerPage = _6 === void 0 ? 50 : _6, _7 = _a.totalRecords, totalRecords = _7 === void 0 ? 0 : _7, onPagination = _a.onPagination, _8 = _a.isTableSettings, isTableSettings = _8 === void 0 ? false : _8, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch, onNoOfRowsPerPageChange = _a.onNoOfRowsPerPageChange, paginationSelectOptions = _a.paginationSelectOptions, tableMaxHeight = _a.tableMaxHeight, minVisibleRows = _a.minVisibleRows, maxVisibleRows = _a.maxVisibleRows, autoFitViewport = _a.autoFitViewport, tableSettings = _a.tableSettings, filterSidebar = _a.filterSidebar, loadingSkeletonRows = _a.loadingSkeletonRows
61
+ var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _0 = _a.isCheckbox, isCheckbox = _0 === void 0 ? false : _0, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _1 = _a.noBorders, noBorders = _1 === void 0 ? false : _1, _2 = _a.isPagination, isPagination = _2 === void 0 ? true : _2, onRowClick = _a.onRowClick, selections = _a.selections, _3 = _a.isActionFreeze, isActionFreeze = _3 === void 0 ? true : _3, _4 = _a.preferences, preferences = _4 === void 0 ? {
62
+ url: "",
63
+ token: "",
64
+ key: "",
65
+ name: "",
66
+ page: "",
67
+ orgId: "",
68
+ } : _4, _5 = _a.paginationMode, paginationMode = _5 === void 0 ? "client" : _5, _6 = _a.noOfRowsPerPage, noOfRowsPerPage = _6 === void 0 ? 50 : _6, _7 = _a.totalRecords, totalRecords = _7 === void 0 ? 0 : _7, onPagination = _a.onPagination, _8 = _a.isTableSettings, isTableSettings = _8 === void 0 ? false : _8, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch, onNoOfRowsPerPageChange = _a.onNoOfRowsPerPageChange, paginationSelectOptions = _a.paginationSelectOptions, tableMaxHeight = _a.tableMaxHeight, minVisibleRows = _a.minVisibleRows, maxVisibleRows = _a.maxVisibleRows, autoFitViewport = _a.autoFitViewport, tableSettings = _a.tableSettings, filterSidebar = _a.filterSidebar, loadingSkeletonRows = _a.loadingSkeletonRows
70
69
  // onColumnFilter
71
70
  ;
72
71
  var theme = (0, useCustomTheme_1.useCustomTheme)();
@@ -120,10 +119,30 @@ function Table(_a) {
120
119
  }, [columnsSearch, filteredData]);
121
120
  var onPaginationRef = (0, react_1.useRef)(onPagination);
122
121
  onPaginationRef.current = onPagination;
122
+ var prevPageRef = (0, react_1.useRef)(currentPage);
123
123
  (0, react_1.useEffect)(function () {
124
- var _a;
125
- (_a = onPaginationRef.current) === null || _a === void 0 ? void 0 : _a.call(onPaginationRef, currentPage + 1, noOfRowsPerPage);
126
- }, [currentPage, noOfRowsPerPage]);
124
+ if (onPaginationRef.current) {
125
+ var prevPage = prevPageRef.current;
126
+ var direction = void 0;
127
+ if (currentPage === 0) {
128
+ direction = "first";
129
+ }
130
+ else if (currentPage === pages - 1) {
131
+ direction = "last";
132
+ }
133
+ else if (currentPage > prevPage) {
134
+ direction = "next";
135
+ }
136
+ else {
137
+ direction = "prev";
138
+ }
139
+ var record = direction === "next" || direction === "last"
140
+ ? (tableData.length > 0 ? tableData[tableData.length - 1] : undefined)
141
+ : (tableData.length > 0 ? tableData[0] : undefined);
142
+ onPaginationRef.current(currentPage + 1, rowsPerPage, record, direction);
143
+ prevPageRef.current = currentPage;
144
+ }
145
+ }, [currentPage, rowsPerPage, pages]);
127
146
  var tablePaginationText = "".concat(startRow + 1, " - ").concat(endRow > tableData.length ? tableData.length : endRow, " of ").concat(isServerPagination ? totalRecords : tableData.length);
128
147
  var controlsHeight = 45;
129
148
  var estimatedRowHeight = 45;
@@ -205,13 +224,13 @@ function Table(_a) {
205
224
  react_1.default.createElement(ActiveFilters_1.default, { columns: columnsList, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch }),
206
225
  react_1.default.createElement(react_2.Box, { ml: "auto", display: "flex", alignItems: "center", gap: 2 },
207
226
  (isPagination || isServerPagination) && !isCompactHeader && (react_1.default.createElement(react_2.Box, { flex: "0 1 280px", minW: 0, overflow: "hidden" },
208
- 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 }))),
227
+ 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, paginationSelectOptions: paginationSelectOptions, isVisiblity: true }))),
209
228
  (isPagination || isServerPagination) && isCompactHeader && tableData.length > 0 && (react_1.default.createElement(react_2.Popover, { placement: "bottom-end" },
210
229
  react_1.default.createElement(react_2.PopoverTrigger, null,
211
230
  react_1.default.createElement(react_2.IconButton, { "aria-label": "More", size: "sm", variant: "ghost", icon: react_1.default.createElement(lucide_react_1.EllipsisVertical, { size: 18, color: (_w = (_v = theme.colors) === null || _v === void 0 ? void 0 : _v.text) === null || _w === void 0 ? void 0 : _w[500] }) })),
212
- react_1.default.createElement(react_2.PopoverContent, { maxW: "18rem", p: 2, overflow: "hidden" },
231
+ react_1.default.createElement(react_2.PopoverContent, { maxW: "22rem", p: 2, overflow: "hidden" },
213
232
  react_1.default.createElement(react_2.PopoverBody, { p: 0 },
214
- 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 }))))))),
233
+ 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, paginationSelectOptions: paginationSelectOptions, isVisiblity: true }))))))),
215
234
  react_1.default.createElement(react_2.TableContainer, { ref: tableContainerRef, position: "relative", h: isTableLoading ? tableMaxH : undefined, maxH: !isTableLoading ? tableMaxH : undefined, pb: isTableLoading ? 0 : compactScrollbarPadding, overflowY: isCompactRows ? "hidden" : "auto", overflowX: "auto", sx: {
216
235
  '&::-webkit-scrollbar': {
217
236
  width: '6px',
@@ -23,7 +23,7 @@ export type TableProps = {
23
23
  paginationMode?: "client" | "server";
24
24
  noOfRowsPerPage?: number;
25
25
  totalRecords?: number;
26
- onPagination?: (page: number, noOfRecords: number) => void;
26
+ onPagination?: (page: number, noOfRecords: number, record: DataObject | undefined, direction: "next" | "prev" | "first" | "last") => void;
27
27
  onNoOfRowsPerPageChange?: (noOfRows: number) => void;
28
28
  paginationSelectOptions?: (number | string)[];
29
29
  tableMaxHeight?: number;
@@ -28,32 +28,17 @@ var useGetPreferences = function (_a) {
28
28
  if (!baseUrl) {
29
29
  return;
30
30
  }
31
- var controller = new AbortController();
32
31
  setLoading(true);
33
32
  var url = constructUrl({ baseUrl: baseUrl, key: key, page: page, name: name, orgId: orgId });
34
33
  fetch(url, {
35
34
  headers: {
36
35
  Authorization: authToken,
37
36
  },
38
- signal: controller.signal,
39
37
  })
40
38
  .then(function (response) { return response.json(); })
41
- .then(function (data) {
42
- if (!controller.signal.aborted) {
43
- setPreferences(data);
44
- }
45
- })
46
- .catch(function (error) {
47
- if (!controller.signal.aborted) {
48
- console.error(error);
49
- }
50
- })
51
- .finally(function () {
52
- if (!controller.signal.aborted) {
53
- setLoading(false);
54
- }
55
- });
56
- return function () { return controller.abort(); };
39
+ .then(function (data) { return setPreferences(data); })
40
+ .catch(function (error) { return console.error(error); })
41
+ .finally(function () { return setLoading(false); });
57
42
  /* eslint-disable */
58
43
  }, [baseUrl]);
59
44
  return { preferences: preferences, loading: loading };
@@ -23,9 +23,8 @@ type TableCellCalculationProps = {
23
23
  row: DataObject;
24
24
  freezedBgColor?: string;
25
25
  index: number;
26
- theme: Record<string, any>;
27
26
  };
28
- export declare const TableCellCalculation: ({ isFrozen, columnWidths, headerIndex, isCheckbox, header, row, freezedBgColor, index, theme, }: TableCellCalculationProps) => {
27
+ export declare const TableCellCalculation: ({ isFrozen, columnWidths, headerIndex, isCheckbox, header, row, freezedBgColor, index, }: TableCellCalculationProps) => {
29
28
  leftOffset: number;
30
29
  cellBgColor: any;
31
30
  rowBgColor: any;
@@ -49,6 +49,7 @@ exports.debounce = debounce;
49
49
  exports.useDebounce = useDebounce;
50
50
  exports.globalSearchFilter = globalSearchFilter;
51
51
  var react_1 = __importStar(require("react"));
52
+ var useCustomTheme_1 = require("../Theme/useCustomTheme");
52
53
  function SortMultiColumnData(data, sortConfig) {
53
54
  if (!sortConfig.length)
54
55
  return data;
@@ -209,7 +210,8 @@ var pageSizeCalculation = function (records) {
209
210
  exports.pageSizeCalculation = pageSizeCalculation;
210
211
  var TableCellCalculation = function (_a) {
211
212
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
212
- 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, theme = _a.theme;
213
+ 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;
214
+ var theme = (0, useCustomTheme_1.useCustomTheme)();
213
215
  var leftOffset = isFrozen
214
216
  ? (0, exports.calculateLeftOffset)(columnWidths, headerIndex) + (isCheckbox ? 50 : 0)
215
217
  : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "2.2.179",
3
+ "version": "2.2.182",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",