@ackplus/react-tanstack-data-table 1.0.24 → 1.0.25

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.24",
4
+ "version": "1.0.25",
5
5
  "description": "A powerful React data table component built with MUI and TanStack Table",
6
6
  "keywords": [
7
7
  "react",
@@ -634,7 +634,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
634
634
  });
635
635
  },
636
636
  resetFilters: () => {
637
- table.resetGlobalFilter();
638
637
  handleColumnFilterStateChange({
639
638
  filters: [],
640
639
  logic: 'AND',
@@ -668,7 +667,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
668
667
  table.resetSorting();
669
668
  },
670
669
  resetSorting: () => {
671
- table.resetSorting();
670
+ table.setSorting(initialStateConfig.sorting || []);
672
671
  },
673
672
  },
674
673
  pagination: {
@@ -711,6 +710,9 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
711
710
  }
712
711
  }
713
712
  },
713
+ resetPagination: () => {
714
+ table.setPagination(initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 });
715
+ },
714
716
  },
715
717
  selection: {
716
718
  selectRow: (rowId) => { var _a; return (_a = table.selectRow) === null || _a === void 0 ? void 0 : _a.call(table, rowId); },
@@ -7,32 +7,34 @@ const material_1 = require("@mui/material");
7
7
  const data_table_context_1 = require("../../contexts/data-table-context");
8
8
  const slot_helpers_1 = require("../../utils/slot-helpers");
9
9
  function ColumnResetControl(props = {}) {
10
- const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
10
+ const { apiRef, table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
11
11
  const resetIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'resetIcon');
12
12
  const ResetIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'resetIcon', icons_material_1.Autorenew);
13
13
  const handleResetLayout = () => {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
14
15
  const actions = props.resetActions || ['columnOrder', 'columnPinning', 'columnSizing'];
16
+ if (!(apiRef === null || apiRef === void 0 ? void 0 : apiRef.current))
17
+ return;
15
18
  if (actions.includes('columnOrder')) {
16
- table.resetColumnOrder();
19
+ (_b = (_a = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _a === void 0 ? void 0 : _a.columnOrdering) === null || _b === void 0 ? void 0 : _b.resetColumnOrder();
17
20
  }
18
21
  if (actions.includes('columnPinning')) {
19
- table.resetColumnPinning();
22
+ (_d = (_c = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _c === void 0 ? void 0 : _c.columnPinning) === null || _d === void 0 ? void 0 : _d.resetColumnPinning();
20
23
  }
21
24
  if (actions.includes('columnSizing')) {
22
- table.resetColumnSizing();
25
+ (_f = (_e = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _e === void 0 ? void 0 : _e.columnResizing) === null || _f === void 0 ? void 0 : _f.resetColumnSizing();
23
26
  }
24
27
  if (actions.includes('columnVisibility')) {
25
- table.resetColumnVisibility();
28
+ (_h = (_g = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _g === void 0 ? void 0 : _g.columnVisibility) === null || _h === void 0 ? void 0 : _h.resetColumnVisibility();
26
29
  }
27
30
  if (actions.includes('filters')) {
28
- table.resetColumnFilters();
29
- table.resetGlobalFilter();
31
+ (_k = (_j = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _j === void 0 ? void 0 : _j.filtering) === null || _k === void 0 ? void 0 : _k.clearAllFilters();
30
32
  }
31
33
  if (actions.includes('sorting')) {
32
- table.resetSorting();
34
+ (_m = (_l = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _l === void 0 ? void 0 : _l.sorting) === null || _m === void 0 ? void 0 : _m.resetSorting();
33
35
  }
34
36
  if (actions.includes('pagination')) {
35
- table.resetPagination();
37
+ (_p = (_o = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _o === void 0 ? void 0 : _o.pagination) === null || _p === void 0 ? void 0 : _p.resetPagination();
36
38
  }
37
39
  };
38
40
  const mergedIconButtonProps = (0, slot_helpers_1.mergeSlotProps)({
@@ -53,6 +53,7 @@ export interface DataTableApi<T = any> {
53
53
  setPageSize: (pageSize: number) => void;
54
54
  goToFirstPage: () => void;
55
55
  goToLastPage: () => void;
56
+ resetPagination?: () => void;
56
57
  };
57
58
  selection: {
58
59
  selectRow: (rowId: string) => void;