@ackplus/react-tanstack-data-table 1.0.21 → 1.0.22

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ackplus/react-tanstack-data-table",
3
3
  "type": "commonjs",
4
- "version": "1.0.21",
4
+ "version": "1.0.22",
5
5
  "description": "A powerful React data table component built with MUI and TanStack Table",
6
6
  "keywords": [
7
7
  "react",
@@ -10,8 +10,6 @@ const slot_helpers_1 = require("../../utils/slot-helpers");
10
10
  exports.DataTablePagination = (0, react_1.memo)((props) => {
11
11
  const { footerFilter = null, pagination, totalRow, containerSx, paginationProps, footerSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["footerFilter", "pagination", "totalRow", "containerSx", "paginationProps", "footerSx", "slots", "slotProps"]);
12
12
  const { table } = (0, data_table_context_1.useDataTableContext)();
13
- const paginationSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'pagination');
14
- const PaginationSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'pagination', material_1.TablePagination);
15
13
  const mergedContainerProps = (0, slot_helpers_1.mergeSlotProps)({
16
14
  sx: Object.assign({ display: 'flex', alignItems: 'center', gap: 1, justifyContent: 'space-between', px: 2 }, containerSx),
17
15
  });
@@ -32,6 +30,6 @@ exports.DataTablePagination = (0, react_1.memo)((props) => {
32
30
  showLastButton: true,
33
31
  labelRowsPerPage: 'Rows per page:',
34
32
  labelDisplayedRows: ({ from, to, count }) => `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`,
35
- }, paginationSlotProps, Object.assign(Object.assign({}, paginationProps), otherProps));
36
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({}, mergedContainerProps, { children: [footerFilter && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: footerSx, children: footerFilter })), (0, jsx_runtime_1.jsx)(PaginationSlot, Object.assign({}, mergedPaginationProps))] })));
33
+ }, Object.assign(Object.assign({}, paginationProps), otherProps));
34
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({}, mergedContainerProps, { children: [footerFilter && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: footerSx, children: footerFilter })), (0, jsx_runtime_1.jsx)(material_1.TablePagination, Object.assign({}, mergedPaginationProps))] })));
37
35
  });
@@ -602,6 +602,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
602
602
  pageSize: ((_a = filters.pagination) === null || _a === void 0 ? void 0 : _a.pageSize) || ((_b = initialStateConfig.pagination) === null || _b === void 0 ? void 0 : _b.pageSize) || 10,
603
603
  };
604
604
  const allState = table.getState();
605
+ setPagination(pagination);
605
606
  onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
606
607
  fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination });
607
608
  },
@@ -35,7 +35,7 @@ function ServerSideFetchingExample() {
35
35
  const apiRef = (0, react_1.useRef)(null);
36
36
  const handleFetchData = (0, react_1.useCallback)((filters) => tslib_1.__awaiter(this, void 0, void 0, function* () {
37
37
  var _a, _b, _c;
38
- console.log('🔄 Fetching data with filters:', filters);
38
+ console.log('🔄 handleFetchData', { filters });
39
39
  setLoading(true);
40
40
  setError(null);
41
41
  setLastFetchParams(filters);
@@ -114,13 +114,12 @@ function ServerSideFetchingExample() {
114
114
  }
115
115
  }), [tab]);
116
116
  const handleSelectionChange = (0, react_1.useCallback)((selection) => {
117
- console.log('🔄 Selection changed:', selection);
118
117
  setSelectionInfo(selection);
119
118
  }, []);
120
119
  (0, react_1.useEffect)(() => {
121
120
  var _a;
122
- console.log('🔄 Tab changed:', tab);
123
- if (tab && tab !== 'all') {
121
+ if (tab) {
122
+ console.log('🔄 Refreshing data');
124
123
  (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.data.refresh();
125
124
  }
126
125
  }, [tab]);
@@ -233,7 +232,7 @@ function ServerSideFetchingExample() {
233
232
  }, children: "Update Selected" })] })), enableGlobalFilter: true, enableColumnFilter: true, enableSorting: true, enablePagination: true, initialState: {
234
233
  pagination: {
235
234
  pageIndex: 0,
236
- pageSize: 10,
235
+ pageSize: 50,
237
236
  },
238
237
  columnPinning: {
239
238
  left: [types_1.DEFAULT_SELECTION_COLUMN_NAME],
@@ -245,5 +244,9 @@ function ServerSideFetchingExample() {
245
244
  console.log('Export completed:', result);
246
245
  }, onExportError: (error) => {
247
246
  console.error('Export error:', error);
248
- }, enableHover: true, enableStripes: true, tableSize: "medium", enableColumnVisibility: true, enableTableSizeControl: true, enableReset: true, emptyMessage: "No employees found matching your criteria", skeletonRows: 10 })] }));
247
+ }, enableHover: true, enableStripes: true, tableSize: "medium", enableColumnVisibility: true, enableTableSizeControl: true, enableReset: true, emptyMessage: "No employees found matching your criteria", skeletonRows: 10, slotProps: {
248
+ pagination: {
249
+ rowsPerPageOptions: [5, 10, 20, 50, 100, 200],
250
+ },
251
+ } })] }));
249
252
  }
@@ -6,21 +6,14 @@ const react_1 = require("react");
6
6
  function useDebouncedFetch(onFetchData, delay = 300) {
7
7
  const [isLoading, setIsLoading] = (0, react_1.useState)(false);
8
8
  const debounceTimer = (0, react_1.useRef)(null);
9
- const lastFetchParams = (0, react_1.useRef)('');
10
9
  const debouncedFetch = (0, react_1.useCallback)((filters) => tslib_1.__awaiter(this, void 0, void 0, function* () {
11
10
  if (!onFetchData)
12
11
  return null;
13
- const currentParams = JSON.stringify(filters);
14
12
  if (debounceTimer.current) {
15
13
  clearTimeout(debounceTimer.current);
16
14
  }
17
15
  return new Promise((resolve) => {
18
16
  debounceTimer.current = setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
19
- if (lastFetchParams.current === currentParams) {
20
- resolve(null);
21
- return;
22
- }
23
- lastFetchParams.current = currentParams;
24
17
  setIsLoading(true);
25
18
  try {
26
19
  const result = yield onFetchData(filters);