@ackplus/react-tanstack-data-table 1.0.19-beta-0.10 → 1.0.19-beta-0.13

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.
Files changed (30) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/src/lib/components/table/data-table.d.ts +2 -1
  4. package/src/lib/components/table/data-table.js +128 -125
  5. package/src/lib/components/table/data-table.types.d.ts +9 -9
  6. package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +1 -1
  7. package/src/lib/components/toolbar/column-filter-control.d.ts +1 -0
  8. package/src/lib/components/toolbar/{column-custom-filter-control.js → column-filter-control.js} +22 -20
  9. package/src/lib/components/toolbar/data-table-toolbar.js +2 -2
  10. package/src/lib/components/toolbar/index.d.ts +1 -0
  11. package/src/lib/components/toolbar/index.js +3 -1
  12. package/src/lib/components/toolbar/table-export-control.d.ts +4 -4
  13. package/src/lib/contexts/data-table-context.d.ts +8 -8
  14. package/src/lib/contexts/data-table-context.js +5 -5
  15. package/src/lib/examples/server-side-fetching-example.js +12 -3
  16. package/src/lib/features/{custom-column-filter.feature.d.ts → column-filter.feature.d.ts} +14 -14
  17. package/src/lib/features/{custom-column-filter.feature.js → column-filter.feature.js} +51 -26
  18. package/src/lib/features/index.d.ts +2 -2
  19. package/src/lib/features/index.js +6 -6
  20. package/src/lib/features/{custom-selection.feature.d.ts → selection.feature.d.ts} +8 -8
  21. package/src/lib/features/{custom-selection.feature.js → selection.feature.js} +20 -8
  22. package/src/lib/hooks/use-data-table-api.d.ts +7 -19
  23. package/src/lib/hooks/use-data-table-api.js +84 -104
  24. package/src/lib/types/data-table-api.d.ts +4 -4
  25. package/src/lib/types/table.types.d.ts +4 -4
  26. package/src/lib/utils/column-helpers.d.ts +1 -2
  27. package/src/lib/utils/column-helpers.js +3 -2
  28. package/src/lib/utils/export-utils.d.ts +4 -4
  29. package/src/lib/utils/export-utils.js +32 -15
  30. package/src/lib/components/toolbar/column-custom-filter-control.d.ts +0 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ColumnCustomFilterControl = ColumnCustomFilterControl;
3
+ exports.ColumnFilterControl = ColumnFilterControl;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const icons_material_1 = require("@mui/icons-material");
6
6
  const material_1 = require("@mui/material");
@@ -12,51 +12,51 @@ const column_helpers_1 = require("../../utils/column-helpers");
12
12
  const slot_helpers_1 = require("../../utils/slot-helpers");
13
13
  const filters_1 = require("../filters");
14
14
  const filter_value_input_1 = require("../filters/filter-value-input");
15
- function ColumnCustomFilterControl() {
15
+ function ColumnFilterControl() {
16
16
  var _a, _b, _c;
17
17
  const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
18
18
  const FilterIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'filterIcon', icons_material_1.FilterList);
19
- const customFilterState = ((_a = table.getCustomColumnFilterState) === null || _a === void 0 ? void 0 : _a.call(table)) || {
19
+ const filterState = ((_a = table === null || table === void 0 ? void 0 : table.getColumnFilterState) === null || _a === void 0 ? void 0 : _a.call(table)) || {
20
20
  filters: [],
21
21
  logic: 'AND',
22
22
  pendingFilters: [],
23
23
  pendingLogic: 'AND'
24
24
  };
25
- const filters = customFilterState.pendingFilters;
26
- const filterLogic = customFilterState.pendingLogic;
27
- const activeFiltersCount = ((_c = (_b = table.getActiveColumnFilters) === null || _b === void 0 ? void 0 : _b.call(table)) === null || _c === void 0 ? void 0 : _c.length) || 0;
25
+ const filters = filterState.pendingFilters;
26
+ const filterLogic = filterState.pendingLogic;
27
+ const activeFiltersCount = ((_c = (_b = table === null || table === void 0 ? void 0 : table.getActiveColumnFilters) === null || _b === void 0 ? void 0 : _b.call(table)) === null || _c === void 0 ? void 0 : _c.length) || 0;
28
28
  const filterableColumns = (0, react_1.useMemo)(() => {
29
- return table.getAllLeafColumns()
30
- .filter(column => (0, column_helpers_1.isColumnFilterable)(column));
29
+ return table === null || table === void 0 ? void 0 : table.getAllLeafColumns().filter(column => (0, column_helpers_1.isColumnFilterable)(column));
31
30
  }, [table]);
32
31
  const addFilter = (0, react_1.useCallback)((columnId, operator) => {
33
32
  var _a, _b;
34
33
  let defaultOperator = operator || '';
34
+ console.log('addFilter', columnId, operator, filterableColumns);
35
35
  if (columnId && !operator) {
36
- const column = filterableColumns.find(col => col.id === columnId);
36
+ const column = filterableColumns === null || filterableColumns === void 0 ? void 0 : filterableColumns.find(col => col.id === columnId);
37
37
  const columnType = (0, column_helpers_1.getColumnType)(column);
38
38
  const operators = filters_1.FILTER_OPERATORS[columnType] || filters_1.FILTER_OPERATORS.text;
39
39
  defaultOperator = ((_a = operators[0]) === null || _a === void 0 ? void 0 : _a.value) || 'contains';
40
40
  }
41
- (_b = table.addPendingColumnFilter) === null || _b === void 0 ? void 0 : _b.call(table, columnId || '', defaultOperator, '');
41
+ (_b = table === null || table === void 0 ? void 0 : table.addPendingColumnFilter) === null || _b === void 0 ? void 0 : _b.call(table, columnId || '', defaultOperator, '');
42
42
  }, [table, filterableColumns]);
43
43
  const handleAddFilter = (0, react_1.useCallback)(() => {
44
44
  addFilter();
45
45
  }, [addFilter]);
46
46
  const updateFilter = (0, react_1.useCallback)((filterId, updates) => {
47
47
  var _a;
48
- (_a = table.updatePendingColumnFilter) === null || _a === void 0 ? void 0 : _a.call(table, filterId, updates);
48
+ (_a = table === null || table === void 0 ? void 0 : table.updatePendingColumnFilter) === null || _a === void 0 ? void 0 : _a.call(table, filterId, updates);
49
49
  }, [table]);
50
50
  const removeFilter = (0, react_1.useCallback)((filterId) => {
51
51
  var _a;
52
- (_a = table.removePendingColumnFilter) === null || _a === void 0 ? void 0 : _a.call(table, filterId);
52
+ (_a = table === null || table === void 0 ? void 0 : table.removePendingColumnFilter) === null || _a === void 0 ? void 0 : _a.call(table, filterId);
53
53
  }, [table]);
54
54
  const clearAllFilters = (0, react_1.useCallback)((closeDialog) => {
55
55
  var _a;
56
- (_a = table.clearAllPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
56
+ (_a = table === null || table === void 0 ? void 0 : table.clearAllPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
57
57
  setTimeout(() => {
58
58
  var _a;
59
- (_a = table.applyPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
59
+ (_a = table === null || table === void 0 ? void 0 : table.applyPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
60
60
  if (closeDialog) {
61
61
  closeDialog();
62
62
  }
@@ -64,24 +64,24 @@ function ColumnCustomFilterControl() {
64
64
  }, [table]);
65
65
  const handleLogicChange = (0, react_1.useCallback)((newLogic) => {
66
66
  var _a;
67
- (_a = table.setPendingFilterLogic) === null || _a === void 0 ? void 0 : _a.call(table, newLogic);
67
+ (_a = table === null || table === void 0 ? void 0 : table.setPendingFilterLogic) === null || _a === void 0 ? void 0 : _a.call(table, newLogic);
68
68
  }, [table]);
69
69
  const applyFilters = (0, react_1.useCallback)(() => {
70
70
  var _a;
71
- (_a = table.applyPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
71
+ (_a = table === null || table === void 0 ? void 0 : table.applyPendingColumnFilters) === null || _a === void 0 ? void 0 : _a.call(table);
72
72
  }, [table]);
73
73
  const handleApplyFilters = (0, react_1.useCallback)((closeDialog) => {
74
74
  applyFilters();
75
75
  closeDialog();
76
76
  }, [applyFilters]);
77
77
  const getOperatorsForColumn = (0, react_1.useCallback)((columnId) => {
78
- const column = filterableColumns.find(col => col.id === columnId);
78
+ const column = filterableColumns === null || filterableColumns === void 0 ? void 0 : filterableColumns.find(col => col.id === columnId);
79
79
  const type = (0, column_helpers_1.getColumnType)(column);
80
80
  return filters_1.FILTER_OPERATORS[type] || filters_1.FILTER_OPERATORS.text;
81
81
  }, [filterableColumns]);
82
82
  const handleColumnChange = (0, react_1.useCallback)((filterId, newColumnId, currentFilter) => {
83
83
  var _a;
84
- const newColumn = filterableColumns.find(col => col.id === newColumnId);
84
+ const newColumn = filterableColumns === null || filterableColumns === void 0 ? void 0 : filterableColumns.find(col => col.id === newColumnId);
85
85
  const columnType = (0, column_helpers_1.getColumnType)(newColumn);
86
86
  const operators = filters_1.FILTER_OPERATORS[columnType] || filters_1.FILTER_OPERATORS.text;
87
87
  const currentOperatorValid = operators.some(op => op.value === currentFilter.operator);
@@ -115,12 +115,14 @@ function ColumnCustomFilterControl() {
115
115
  const hasPendingChanges = pendingFiltersCount > 0 || (filters.length === 0 && hasAppliedFilters);
116
116
  (0, react_1.useEffect)(() => {
117
117
  var _a;
118
- if (filters.length === 0 && filterableColumns.length > 0 && activeFiltersCount === 0) {
118
+ console.log('useEffect', filters.length, filterableColumns, { activeFiltersCount });
119
+ if (filters.length === 0 && filterableColumns && (filterableColumns === null || filterableColumns === void 0 ? void 0 : filterableColumns.length) > 0 && activeFiltersCount === 0) {
119
120
  const firstColumn = filterableColumns[0];
120
121
  const columnType = (0, column_helpers_1.getColumnType)(firstColumn);
121
122
  const operators = filters_1.FILTER_OPERATORS[columnType] || filters_1.FILTER_OPERATORS.text;
122
123
  const defaultOperator = ((_a = operators[0]) === null || _a === void 0 ? void 0 : _a.value) || 'contains';
123
- addFilter(firstColumn.id, defaultOperator);
124
+ console.log('useEffect', firstColumn, columnType, operators, defaultOperator);
125
+ addFilter(firstColumn === null || firstColumn === void 0 ? void 0 : firstColumn.id, defaultOperator);
124
126
  }
125
127
  }, [filters.length, filterableColumns, addFilter, activeFiltersCount]);
126
128
  return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Badge, { variant: "dot", color: "primary", invisible: activeFiltersCount === 0, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", color: activeFiltersCount > 0 ? 'primary' : 'default', sx: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataTableToolbar = DataTableToolbar;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const material_1 = require("@mui/material");
6
- const column_custom_filter_control_1 = require("./column-custom-filter-control");
6
+ const column_filter_control_1 = require("./column-filter-control");
7
7
  const column_pinning_control_1 = require("./column-pinning-control");
8
8
  const column_reset_control_1 = require("./column-reset-control");
9
9
  const column_visibility_control_1 = require("./column-visibility-control");
@@ -17,7 +17,7 @@ function DataTableToolbar({ extraFilter = null, enableGlobalFilter = true, title
17
17
  const ToolbarSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'toolbar', material_1.Toolbar);
18
18
  const TableSearchControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'searchInput', table_search_control_1.TableSearchControl);
19
19
  const TableSizeControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeControl', table_size_control_1.TableSizeControl);
20
- const ColumnCustomFilterControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnCustomFilterControl', column_custom_filter_control_1.ColumnCustomFilterControl);
20
+ const ColumnCustomFilterControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnCustomFilterControl', column_filter_control_1.ColumnFilterControl);
21
21
  const ColumnPinningControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnPinningControl', column_pinning_control_1.ColumnPinningControl);
22
22
  const ColumnVisibilityControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnVisibilityControl', column_visibility_control_1.ColumnVisibilityControl);
23
23
  const ColumnResetControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'resetButton', column_reset_control_1.ColumnResetControl);
@@ -4,5 +4,6 @@ export { ColumnPinningControl } from './column-pinning-control';
4
4
  export { ColumnResetControl } from './column-reset-control';
5
5
  export { TableExportControl } from './table-export-control';
6
6
  export { TableSizeControl } from './table-size-control';
7
+ export { ColumnFilterControl } from './column-filter-control';
7
8
  export { BulkActionsToolbar } from './bulk-actions-toolbar';
8
9
  export type { BulkActionsToolbarProps } from './bulk-actions-toolbar';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BulkActionsToolbar = exports.TableSizeControl = exports.TableExportControl = exports.ColumnResetControl = exports.ColumnPinningControl = exports.ColumnVisibilityControl = exports.DataTableToolbar = void 0;
3
+ exports.BulkActionsToolbar = exports.ColumnFilterControl = exports.TableSizeControl = exports.TableExportControl = exports.ColumnResetControl = exports.ColumnPinningControl = exports.ColumnVisibilityControl = exports.DataTableToolbar = void 0;
4
4
  var data_table_toolbar_1 = require("./data-table-toolbar");
5
5
  Object.defineProperty(exports, "DataTableToolbar", { enumerable: true, get: function () { return data_table_toolbar_1.DataTableToolbar; } });
6
6
  var column_visibility_control_1 = require("./column-visibility-control");
@@ -13,5 +13,7 @@ var table_export_control_1 = require("./table-export-control");
13
13
  Object.defineProperty(exports, "TableExportControl", { enumerable: true, get: function () { return table_export_control_1.TableExportControl; } });
14
14
  var table_size_control_1 = require("./table-size-control");
15
15
  Object.defineProperty(exports, "TableSizeControl", { enumerable: true, get: function () { return table_size_control_1.TableSizeControl; } });
16
+ var column_filter_control_1 = require("./column-filter-control");
17
+ Object.defineProperty(exports, "ColumnFilterControl", { enumerable: true, get: function () { return column_filter_control_1.ColumnFilterControl; } });
16
18
  var bulk_actions_toolbar_1 = require("./bulk-actions-toolbar");
17
19
  Object.defineProperty(exports, "BulkActionsToolbar", { enumerable: true, get: function () { return bulk_actions_toolbar_1.BulkActionsToolbar; } });
@@ -1,5 +1,5 @@
1
1
  import { TableFilters } from '../../types';
2
- import { SelectionState } from '../../features/custom-selection.feature';
2
+ import { SelectionState } from '../../features';
3
3
  interface TableExportControlProps {
4
4
  exportFilename?: string;
5
5
  onServerExport?: (filters?: Partial<TableFilters>, selection?: SelectionState) => Promise<{
@@ -7,9 +7,9 @@ interface TableExportControlProps {
7
7
  total: number;
8
8
  }>;
9
9
  onExportProgress?: (progress: {
10
- processedRows: number;
11
- totalRows: number;
12
- percentage: number;
10
+ processedRows?: number;
11
+ totalRows?: number;
12
+ percentage?: number;
13
13
  }) => void;
14
14
  onExportComplete?: (result: {
15
15
  success: boolean;
@@ -1,15 +1,15 @@
1
1
  import { Table } from '@tanstack/react-table';
2
2
  import { ReactNode, RefObject } from 'react';
3
- import { CustomColumnFilterState, TableSize } from '../types';
3
+ import { ColumnFilterState, TableSize } from '../types';
4
4
  import { DataTableApi } from '../types/data-table-api';
5
5
  interface DataTableContextValue<T = any> {
6
6
  table?: Table<T>;
7
- apiRef?: RefObject<DataTableApi<T>>;
7
+ apiRef?: RefObject<DataTableApi<T> | null>;
8
8
  dataMode?: 'client' | 'server';
9
9
  tableSize?: TableSize;
10
10
  onTableSizeChange?: (size: TableSize) => void;
11
- customColumnsFilter?: CustomColumnFilterState;
12
- onChangeCustomColumnsFilter?: (filter: CustomColumnFilterState) => void;
11
+ columnFilter?: ColumnFilterState;
12
+ onChangeColumnFilter?: (filter: ColumnFilterState) => void;
13
13
  slots?: Record<string, any>;
14
14
  slotProps?: Record<string, any>;
15
15
  isExporting?: boolean;
@@ -17,9 +17,9 @@ interface DataTableContextValue<T = any> {
17
17
  onCancelExport?: () => void;
18
18
  exportFilename?: string;
19
19
  onExportProgress?: (progress: {
20
- processedRows: number;
21
- totalRows: number;
22
- percentage: number;
20
+ processedRows?: number;
21
+ totalRows?: number;
22
+ percentage?: number;
23
23
  }) => void;
24
24
  onExportComplete?: (result: {
25
25
  success: boolean;
@@ -38,6 +38,6 @@ interface DataTableContextValue<T = any> {
38
38
  interface DataTableProviderProps<T = any> extends DataTableContextValue<T> {
39
39
  children: ReactNode;
40
40
  }
41
- export declare function DataTableProvider<T = any>({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, customColumnsFilter, onChangeCustomColumnsFilter, slots, slotProps, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }: DataTableProviderProps<T>): import("react/jsx-runtime").JSX.Element;
41
+ export declare function DataTableProvider<T = any>({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, columnFilter, onChangeColumnFilter, slots, slotProps, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }: DataTableProviderProps<T>): import("react/jsx-runtime").JSX.Element;
42
42
  export declare function useDataTableContext<T = any>(): DataTableContextValue<T>;
43
43
  export {};
@@ -5,15 +5,15 @@ exports.useDataTableContext = useDataTableContext;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = require("react");
7
7
  const DataTableContext = (0, react_1.createContext)(null);
8
- function DataTableProvider({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, customColumnsFilter, onChangeCustomColumnsFilter, slots = {}, slotProps = {}, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }) {
8
+ function DataTableProvider({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, columnFilter, onChangeColumnFilter, slots = {}, slotProps = {}, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }) {
9
9
  const value = (0, react_1.useMemo)(() => ({
10
10
  table,
11
11
  apiRef,
12
12
  dataMode,
13
13
  tableSize,
14
14
  onTableSizeChange,
15
- customColumnsFilter,
16
- onChangeCustomColumnsFilter,
15
+ columnFilter,
16
+ onChangeColumnFilter,
17
17
  slots,
18
18
  slotProps,
19
19
  isExporting,
@@ -30,8 +30,8 @@ function DataTableProvider({ children, table, apiRef, dataMode, tableSize, onTab
30
30
  dataMode,
31
31
  tableSize,
32
32
  onTableSizeChange,
33
- customColumnsFilter,
34
- onChangeCustomColumnsFilter,
33
+ columnFilter,
34
+ onChangeColumnFilter,
35
35
  slots,
36
36
  slotProps,
37
37
  isExporting,
@@ -30,10 +30,12 @@ function ServerSideFetchingExample() {
30
30
  const [selectionInfo, setSelectionInfo] = (0, react_1.useState)(null);
31
31
  const [lastFetchParams, setLastFetchParams] = (0, react_1.useState)(null);
32
32
  const [fetchCount, setFetchCount] = (0, react_1.useState)(0);
33
+ const [tab, setTab] = (0, react_1.useState)('all');
33
34
  const apiRef = (0, react_1.useRef)(null);
34
35
  const handleFetchData = (0, react_1.useCallback)((filters) => tslib_1.__awaiter(this, void 0, void 0, function* () {
35
36
  var _a, _b, _c;
36
37
  console.log('🔄 Fetching data with filters:', filters);
38
+ console.log('🔄 Tab:', { tab }, 'Current tab:');
37
39
  setLoading(true);
38
40
  setError(null);
39
41
  setLastFetchParams(filters);
@@ -48,9 +50,9 @@ function ServerSideFetchingExample() {
48
50
  employee.department.toLowerCase().includes(searchTerm) ||
49
51
  employee.role.toLowerCase().includes(searchTerm));
50
52
  }
51
- if ((_b = (_a = filters.customColumnsFilter) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.length) {
53
+ if ((_b = (_a = filters.columnFilter) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.length) {
52
54
  filteredData = filteredData.filter(employee => {
53
- return filters.customColumnsFilter.filters.every((filter) => {
55
+ return filters.columnFilter.filters.every((filter) => {
54
56
  const value = employee[filter.columnId];
55
57
  const filterValue = filter.value;
56
58
  switch (filter.operator) {
@@ -120,6 +122,13 @@ function ServerSideFetchingExample() {
120
122
  console.log('🔄 Selection changed:', selection);
121
123
  setSelectionInfo(selection);
122
124
  }, []);
125
+ (0, react_1.useEffect)(() => {
126
+ var _a;
127
+ console.log('🔄 Tab changed:', tab);
128
+ if (tab && tab !== 'all') {
129
+ (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.data.refresh();
130
+ }
131
+ }, [tab]);
123
132
  const handleServerExport = (0, react_1.useCallback)((filters, selection) => tslib_1.__awaiter(this, void 0, void 0, function* () {
124
133
  console.log('📤 Exporting data with filters:', filters);
125
134
  console.log('📤 Export selection:', selection);
@@ -196,7 +205,7 @@ function ServerSideFetchingExample() {
196
205
  accessorFn: (row) => new Date(row.joinDate).toLocaleDateString(),
197
206
  },
198
207
  ];
199
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { p: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", gutterBottom: true, children: "Server-Side Data Fetching Example" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", paragraph: true, children: "Demonstrates server-side data fetching with proper API ref state management and page-based selection. The Salary column has `hideInExport: true` so it will be excluded from exports." }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, sx: { mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: "primary", children: fetchCount }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "API Calls Made" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: "secondary", children: (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.ids.length) || 0 }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Selected Items" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: loading ? 'warning.main' : 'success.main', children: loading ? 'Loading...' : 'Ready' }), loading && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 16 })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Server Status" })] }) })] }), error && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 3 }, children: error })), (0, jsx_runtime_1.jsx)(material_1.Card, { sx: { mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "API Controls (via apiRef)" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
208
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { p: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", gutterBottom: true, children: "Server-Side Data Fetching Example" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", paragraph: true, children: "Demonstrates server-side data fetching with proper API ref state management and page-based selection. The Salary column has `hideInExport: true` so it will be excluded from exports." }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => setTab('all'), children: "All" }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => setTab('active'), children: "Active" }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => setTab('inactive'), children: "Inactive" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, sx: { mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: "primary", children: fetchCount }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "API Calls Made" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: "secondary", children: (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.ids.length) || 0 }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Selected Items" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: loading ? 'warning.main' : 'success.main', children: loading ? 'Loading...' : 'Ready' }), loading && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 16 })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Server Status" })] }) })] }), error && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 3 }, children: error })), (0, jsx_runtime_1.jsx)(material_1.Card, { sx: { mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "API Controls (via apiRef)" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
200
209
  var _a;
201
210
  const state = (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.selection.getSelectionState();
202
211
  console.log('Current Selection State:', state);
@@ -1,5 +1,5 @@
1
1
  import { Table, TableFeature, RowData, Updater, RowModel } from '@tanstack/react-table';
2
- import type { CustomColumnFilterState } from '../types/table.types';
2
+ import type { ColumnFilterState } from '../types/table.types';
3
3
  export interface ColumnFilterRule {
4
4
  id: string;
5
5
  columnId: string;
@@ -7,24 +7,24 @@ export interface ColumnFilterRule {
7
7
  value: any;
8
8
  columnType?: string;
9
9
  }
10
- export interface CustomColumnFilterOptions {
11
- enableCustomColumnFilter?: boolean;
12
- onCustomColumnFilterChange?: (updater: Updater<CustomColumnFilterState>) => void;
13
- onCustomColumnFilterApply?: (state: CustomColumnFilterState) => void;
10
+ export interface ColumnFilterOptions {
11
+ enableAdvanceColumnFilter?: boolean;
12
+ onColumnFilterChange?: (updater: Updater<ColumnFilterState>) => void;
13
+ onColumnFilterApply?: (state: ColumnFilterState) => void;
14
14
  }
15
- export interface CustomColumnFilterTableState {
16
- customColumnFilter: CustomColumnFilterState;
15
+ export interface ColumnFilterTableState {
16
+ columnFilter: ColumnFilterState;
17
17
  }
18
18
  declare module '@tanstack/table-core' {
19
- interface TableState extends CustomColumnFilterTableState {
19
+ interface TableState extends ColumnFilterTableState {
20
20
  }
21
- interface TableOptionsResolved<TData extends RowData> extends CustomColumnFilterOptions {
21
+ interface TableOptionsResolved<TData extends RowData> extends ColumnFilterOptions {
22
22
  }
23
- interface Table<TData extends RowData> extends CustomColumnFilterInstance<TData> {
23
+ interface Table<TData extends RowData> extends ColumnFilterInstance<TData> {
24
24
  }
25
25
  }
26
- export interface CustomColumnFilterInstance<TData extends RowData> {
27
- setCustomColumnFilter: (updater: Updater<CustomColumnFilterState>) => void;
26
+ export interface ColumnFilterInstance<TData extends RowData> {
27
+ setColumnFilterState: (updater: Updater<ColumnFilterState>) => void;
28
28
  addPendingColumnFilter: (columnId: string, operator: string, value: any) => void;
29
29
  updatePendingColumnFilter: (filterId: string, updates: Partial<ColumnFilterRule>) => void;
30
30
  removePendingColumnFilter: (filterId: string) => void;
@@ -38,8 +38,8 @@ export interface CustomColumnFilterInstance<TData extends RowData> {
38
38
  setFilterLogic: (logic: 'AND' | 'OR') => void;
39
39
  getActiveColumnFilters: () => ColumnFilterRule[];
40
40
  getPendingColumnFilters: () => ColumnFilterRule[];
41
- getCustomColumnFilterState: () => CustomColumnFilterState;
41
+ getColumnFilterState: () => ColumnFilterState;
42
42
  }
43
- export declare const CustomColumnFilterFeature: TableFeature<any>;
43
+ export declare const ColumnFilterFeature: TableFeature<any>;
44
44
  export declare function matchesCustomColumnFilters<TData extends RowData>(row: any, filters: ColumnFilterRule[], logic?: 'AND' | 'OR'): boolean;
45
45
  export declare const getCombinedFilteredRowModel: <TData>() => (table: Table<TData>) => () => RowModel<TData>;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCombinedFilteredRowModel = exports.CustomColumnFilterFeature = void 0;
3
+ exports.getCombinedFilteredRowModel = exports.ColumnFilterFeature = void 0;
4
4
  exports.matchesCustomColumnFilters = matchesCustomColumnFilters;
5
5
  const tslib_1 = require("tslib");
6
6
  const react_table_1 = require("@tanstack/react-table");
7
7
  const moment_1 = tslib_1.__importDefault(require("moment"));
8
- exports.CustomColumnFilterFeature = {
8
+ exports.ColumnFilterFeature = {
9
9
  getInitialState: (state) => {
10
- return Object.assign({ customColumnFilter: {
10
+ return Object.assign({ columnFilter: {
11
11
  filters: [],
12
12
  logic: 'AND',
13
13
  pendingFilters: [],
@@ -16,23 +16,28 @@ exports.CustomColumnFilterFeature = {
16
16
  },
17
17
  getDefaultOptions: (table) => {
18
18
  return {
19
- enableCustomColumnFilter: true,
20
- onCustomColumnFilterChange: (0, react_table_1.makeStateUpdater)('customColumnFilter', table),
21
- onCustomColumnFilterApply: (state) => {
19
+ enableAdvanceColumnFilter: true,
20
+ onColumnFilterChange: (0, react_table_1.makeStateUpdater)('columnFilter', table),
21
+ onColumnFilterApply: (state) => {
22
22
  },
23
23
  };
24
24
  },
25
25
  createTable: (table) => {
26
- table.setCustomColumnFilter = (updater) => {
26
+ table.setColumnFilterState = (updater) => {
27
27
  var _a, _b;
28
+ if (!table.options.enableAdvanceColumnFilter)
29
+ return;
28
30
  const safeUpdater = (old) => {
29
31
  const newState = (0, react_table_1.functionalUpdate)(updater, old);
30
32
  return newState;
31
33
  };
32
- return (_b = (_a = table.options).onCustomColumnFilterChange) === null || _b === void 0 ? void 0 : _b.call(_a, safeUpdater);
34
+ return (_b = (_a = table.options).onColumnFilterChange) === null || _b === void 0 ? void 0 : _b.call(_a, safeUpdater);
33
35
  };
34
36
  table.addPendingColumnFilter = (columnId, operator, value) => {
35
- table.setCustomColumnFilter((old) => {
37
+ if (!table.options.enableAdvanceColumnFilter)
38
+ return;
39
+ console.log('addPendingColumnFilter', columnId, operator, value);
40
+ table.setColumnFilterState((old) => {
36
41
  const newFilter = {
37
42
  id: `filter_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
38
43
  columnId,
@@ -43,32 +48,44 @@ exports.CustomColumnFilterFeature = {
43
48
  });
44
49
  };
45
50
  table.updatePendingColumnFilter = (filterId, updates) => {
46
- table.setCustomColumnFilter((old) => {
51
+ if (!table.options.enableAdvanceColumnFilter)
52
+ return;
53
+ table.setColumnFilterState((old) => {
47
54
  const updatedFilters = old.pendingFilters.map((filter) => filter.id === filterId ? Object.assign(Object.assign({}, filter), updates) : filter);
48
55
  return Object.assign(Object.assign({}, old), { pendingFilters: updatedFilters });
49
56
  });
50
57
  };
51
58
  table.removePendingColumnFilter = (filterId) => {
52
- table.setCustomColumnFilter((old) => (Object.assign(Object.assign({}, old), { pendingFilters: old.pendingFilters.filter((filter) => filter.id !== filterId) })));
59
+ if (!table.options.enableAdvanceColumnFilter)
60
+ return;
61
+ table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { pendingFilters: old.pendingFilters.filter((filter) => filter.id !== filterId) })));
53
62
  };
54
63
  table.clearAllPendingColumnFilters = () => {
55
- table.setCustomColumnFilter((old) => (Object.assign(Object.assign({}, old), { pendingFilters: [] })));
64
+ if (!table.options.enableAdvanceColumnFilter)
65
+ return;
66
+ table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { pendingFilters: [] })));
56
67
  };
57
68
  table.setPendingFilterLogic = (logic) => {
58
- table.setCustomColumnFilter((old) => (Object.assign(Object.assign({}, old), { pendingLogic: logic })));
69
+ if (!table.options.enableAdvanceColumnFilter)
70
+ return;
71
+ table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { pendingLogic: logic })));
59
72
  };
60
73
  table.applyPendingColumnFilters = () => {
61
- table.setCustomColumnFilter((old) => {
74
+ if (!table.options.enableAdvanceColumnFilter)
75
+ return;
76
+ table.setColumnFilterState((old) => {
62
77
  const newState = Object.assign(Object.assign({}, old), { filters: [...old.pendingFilters], logic: old.pendingLogic });
63
78
  setTimeout(() => {
64
79
  var _a, _b;
65
- (_b = (_a = table.options).onCustomColumnFilterApply) === null || _b === void 0 ? void 0 : _b.call(_a, newState);
80
+ (_b = (_a = table.options).onColumnFilterApply) === null || _b === void 0 ? void 0 : _b.call(_a, newState);
66
81
  }, 0);
67
82
  return newState;
68
83
  });
69
84
  };
70
85
  table.addColumnFilter = (columnId, operator, value) => {
71
- table.setCustomColumnFilter((old) => {
86
+ if (!table.options.enableAdvanceColumnFilter)
87
+ return;
88
+ table.setColumnFilterState((old) => {
72
89
  const newFilter = {
73
90
  id: `filter_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
74
91
  columnId,
@@ -79,30 +96,38 @@ exports.CustomColumnFilterFeature = {
79
96
  });
80
97
  };
81
98
  table.updateColumnFilter = (filterId, updates) => {
82
- table.setCustomColumnFilter((old) => {
99
+ if (!table.options.enableAdvanceColumnFilter)
100
+ return;
101
+ table.setColumnFilterState((old) => {
83
102
  const updatedFilters = old.filters.map((filter) => filter.id === filterId ? Object.assign(Object.assign({}, filter), updates) : filter);
84
103
  return Object.assign(Object.assign({}, old), { filters: updatedFilters });
85
104
  });
86
105
  };
87
106
  table.removeColumnFilter = (filterId) => {
88
- table.setCustomColumnFilter((old) => (Object.assign(Object.assign({}, old), { filters: old.filters.filter((filter) => filter.id !== filterId) })));
107
+ if (!table.options.enableAdvanceColumnFilter)
108
+ return;
109
+ table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { filters: old.filters.filter((filter) => filter.id !== filterId) })));
89
110
  };
90
111
  table.clearAllColumnFilters = () => {
91
- table.setCustomColumnFilter((old) => (Object.assign(Object.assign({}, old), { filters: [] })));
112
+ if (!table.options.enableAdvanceColumnFilter)
113
+ return;
114
+ table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { filters: [] })));
92
115
  };
93
116
  table.setFilterLogic = (logic) => {
94
- table.setCustomColumnFilter((old) => (Object.assign(Object.assign({}, old), { logic })));
117
+ if (!table.options.enableAdvanceColumnFilter)
118
+ return;
119
+ table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { logic })));
95
120
  };
96
121
  table.getActiveColumnFilters = () => {
97
- const state = table.getState().customColumnFilter;
122
+ const state = table.getState().columnFilter;
98
123
  return state.filters.filter((f) => f.columnId && f.operator);
99
124
  };
100
125
  table.getPendingColumnFilters = () => {
101
- const state = table.getState().customColumnFilter;
126
+ const state = table.getState().columnFilter;
102
127
  return state.pendingFilters.filter((f) => f.columnId && f.operator);
103
128
  };
104
- table.getCustomColumnFilterState = () => {
105
- return table.getState().customColumnFilter;
129
+ table.getColumnFilterState = () => {
130
+ return table.getState().columnFilter;
106
131
  };
107
132
  },
108
133
  };
@@ -137,11 +162,11 @@ const getCombinedFilteredRowModel = () => {
137
162
  return (table) => () => {
138
163
  var _a;
139
164
  const baseFilteredModel = (0, react_table_1.getFilteredRowModel)()(table)();
140
- const { filters, logic } = (_a = table.getState().customColumnFilter) !== null && _a !== void 0 ? _a : {
165
+ const { filters, logic } = (_a = table.getState().columnFilter) !== null && _a !== void 0 ? _a : {
141
166
  filters: [],
142
167
  logic: 'AND',
143
168
  };
144
- if (!filters.length)
169
+ if (!filters.length || !table.options.enableAdvanceColumnFilter)
145
170
  return baseFilteredModel;
146
171
  const filteredRows = baseFilteredModel.rows.filter(row => matchesCustomColumnFilters(row, filters, logic));
147
172
  const flatRows = [];
@@ -1,2 +1,2 @@
1
- export { CustomColumnFilterFeature, matchesCustomColumnFilters, type ColumnFilterRule, type CustomColumnFilterOptions, type CustomColumnFilterTableState, type CustomColumnFilterInstance, } from './custom-column-filter.feature';
2
- export { CustomSelectionFeature, type SelectionState, type SelectMode, type CustomSelectionOptions, type CustomSelectionTableState, type CustomSelectionInstance, } from './custom-selection.feature';
1
+ export { ColumnFilterFeature, matchesCustomColumnFilters, type ColumnFilterRule, type ColumnFilterOptions, type ColumnFilterTableState, type ColumnFilterInstance, } from './column-filter.feature';
2
+ export { SelectionFeature, type SelectionState, type SelectMode, type SelectionOptions, type SelectionTableState, type SelectionInstance, } from './selection.feature';
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomSelectionFeature = exports.matchesCustomColumnFilters = exports.CustomColumnFilterFeature = void 0;
4
- var custom_column_filter_feature_1 = require("./custom-column-filter.feature");
5
- Object.defineProperty(exports, "CustomColumnFilterFeature", { enumerable: true, get: function () { return custom_column_filter_feature_1.CustomColumnFilterFeature; } });
6
- Object.defineProperty(exports, "matchesCustomColumnFilters", { enumerable: true, get: function () { return custom_column_filter_feature_1.matchesCustomColumnFilters; } });
7
- var custom_selection_feature_1 = require("./custom-selection.feature");
8
- Object.defineProperty(exports, "CustomSelectionFeature", { enumerable: true, get: function () { return custom_selection_feature_1.CustomSelectionFeature; } });
3
+ exports.SelectionFeature = exports.matchesCustomColumnFilters = exports.ColumnFilterFeature = void 0;
4
+ var column_filter_feature_1 = require("./column-filter.feature");
5
+ Object.defineProperty(exports, "ColumnFilterFeature", { enumerable: true, get: function () { return column_filter_feature_1.ColumnFilterFeature; } });
6
+ Object.defineProperty(exports, "matchesCustomColumnFilters", { enumerable: true, get: function () { return column_filter_feature_1.matchesCustomColumnFilters; } });
7
+ var selection_feature_1 = require("./selection.feature");
8
+ Object.defineProperty(exports, "SelectionFeature", { enumerable: true, get: function () { return selection_feature_1.SelectionFeature; } });
@@ -9,24 +9,24 @@ export type IsRowSelectableFunction<T = any> = (params: {
9
9
  id: string;
10
10
  }) => boolean;
11
11
  export type SelectMode = 'page' | 'all';
12
- export interface CustomSelectionOptions {
13
- enableCustomSelection?: boolean;
12
+ export interface SelectionOptions {
13
+ enableAdvanceSelection?: boolean;
14
14
  selectMode?: SelectMode;
15
15
  isRowSelectable?: IsRowSelectableFunction;
16
16
  onSelectionStateChange?: (updater: Updater<SelectionState>) => void;
17
17
  }
18
- export interface CustomSelectionTableState {
18
+ export interface SelectionTableState {
19
19
  selectionState: SelectionState;
20
20
  }
21
21
  declare module '@tanstack/table-core' {
22
- interface TableState extends CustomSelectionTableState {
22
+ interface TableState extends SelectionTableState {
23
23
  }
24
- interface TableOptionsResolved<TData extends RowData> extends CustomSelectionOptions {
24
+ interface TableOptionsResolved<TData extends RowData> extends SelectionOptions {
25
25
  }
26
- interface Table<TData extends RowData> extends CustomSelectionInstance<TData> {
26
+ interface Table<TData extends RowData> extends SelectionInstance<TData> {
27
27
  }
28
28
  }
29
- export interface CustomSelectionInstance<TData extends RowData> {
29
+ export interface SelectionInstance<TData extends RowData> {
30
30
  setSelectionState: (updater: Updater<SelectionState>) => void;
31
31
  toggleAllRowsSelected: () => void;
32
32
  toggleRowSelected: (rowId: string) => void;
@@ -43,4 +43,4 @@ export interface CustomSelectionInstance<TData extends RowData> {
43
43
  getSelectedRowIds: () => string[];
44
44
  canSelectRow: (rowId: string) => boolean;
45
45
  }
46
- export declare const CustomSelectionFeature: TableFeature<any>;
46
+ export declare const SelectionFeature: TableFeature<any>;