@ackplus/react-tanstack-data-table 1.0.29 → 1.0.31
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 +1 -1
- package/src/lib/components/table/data-table.js +130 -109
- package/src/lib/components/table/data-table.types.d.ts +2 -1
- package/src/lib/components/toolbar/column-pinning-control.js +6 -6
- package/src/lib/components/toolbar/column-visibility-control.js +4 -4
- package/src/lib/types/data-table-api.d.ts +1 -1
package/package.json
CHANGED
|
@@ -32,6 +32,7 @@ const DEFAULT_INITIAL_STATE = {
|
|
|
32
32
|
left: [],
|
|
33
33
|
right: [],
|
|
34
34
|
},
|
|
35
|
+
columnVisibility: {},
|
|
35
36
|
columnFilter: {
|
|
36
37
|
filters: [],
|
|
37
38
|
logic: 'AND',
|
|
@@ -39,16 +40,13 @@ const DEFAULT_INITIAL_STATE = {
|
|
|
39
40
|
pendingLogic: 'AND',
|
|
40
41
|
},
|
|
41
42
|
};
|
|
42
|
-
exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, columns, data = [], totalRow = 0, idKey = 'id', extraFilter = null, footerFilter = null, dataMode = 'client', initialLoadData = true, onFetchData, onDataStateChange, enableRowSelection = false, enableMultiRowSelection = true, selectMode = 'page', isRowSelectable, onSelectionChange, enableBulkActions = false, bulkActions, enableColumnResizing = false, columnResizeMode = 'onChange', enableColumnDragging = false, onColumnDragEnd, enableColumnPinning = false, onColumnPinningChange, enableExpanding = false, getRowCanExpand, renderSubComponent, enablePagination = false, paginationMode = 'client', enableGlobalFilter = true, enableColumnFilter = false, filterMode = 'client', enableSorting = true, sortingMode = 'client', onSortingChange, exportFilename = 'export', onExportProgress, onExportComplete, onExportError, onServerExport, onExportCancel, enableHover = true, enableStripes = false, tableProps = {}, fitToScreen = true, tableSize: initialTableSize = 'medium', enableStickyHeaderOrFooter = false, maxHeight = '400px', enableVirtualization = false, estimateRowHeight = 52,
|
|
43
|
+
exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, columns, data = [], totalRow = 0, idKey = 'id', extraFilter = null, footerFilter = null, dataMode = 'client', initialLoadData = true, onFetchData, onDataStateChange, enableRowSelection = false, enableMultiRowSelection = true, selectMode = 'page', isRowSelectable, onSelectionChange, enableBulkActions = false, bulkActions, enableColumnResizing = false, columnResizeMode = 'onChange', enableColumnDragging = false, onColumnDragEnd, enableColumnPinning = false, onColumnPinningChange, onColumnVisibilityChange, enableColumnVisibility = true, enableExpanding = false, getRowCanExpand, renderSubComponent, enablePagination = false, paginationMode = 'client', enableGlobalFilter = true, enableColumnFilter = false, filterMode = 'client', enableSorting = true, sortingMode = 'client', onSortingChange, exportFilename = 'export', onExportProgress, onExportComplete, onExportError, onServerExport, onExportCancel, enableHover = true, enableStripes = false, tableProps = {}, fitToScreen = true, tableSize: initialTableSize = 'medium', enableStickyHeaderOrFooter = false, maxHeight = '400px', enableVirtualization = false, estimateRowHeight = 52, enableTableSizeControl = true, enableExport = false, enableReset = true, loading = false, emptyMessage = 'No data available', skeletonRows = 5, onColumnFiltersChange, onPaginationChange, onGlobalFilterChange, slots = {}, slotProps = {}, logging, }, ref) {
|
|
43
44
|
var _a;
|
|
44
45
|
const isServerMode = dataMode === 'server';
|
|
45
46
|
const isServerPagination = paginationMode === 'server' || isServerMode;
|
|
46
47
|
const isServerFiltering = filterMode === 'server' || isServerMode;
|
|
47
48
|
const isServerSorting = sortingMode === 'server' || isServerMode;
|
|
48
49
|
const logger = (0, react_1.useMemo)(() => (0, utils_1.createLogger)('DataTable', logging), [logging]);
|
|
49
|
-
const fetchLogger = (0, react_1.useMemo)(() => logger.child('fetch'), [logger]);
|
|
50
|
-
const paginationLogger = (0, react_1.useMemo)(() => logger.child('pagination'), [logger]);
|
|
51
|
-
const stateLogger = (0, react_1.useMemo)(() => logger.child('state'), [logger]);
|
|
52
50
|
(0, react_1.useEffect)(() => {
|
|
53
51
|
if (logger.isLevelEnabled('info')) {
|
|
54
52
|
logger.info('mounted', {
|
|
@@ -71,6 +69,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
71
69
|
}
|
|
72
70
|
return config;
|
|
73
71
|
}, [initialState, logger]);
|
|
72
|
+
console.log('initialStateConfig', initialStateConfig);
|
|
74
73
|
const [sorting, setSorting] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.sorting) || DEFAULT_INITIAL_STATE.sorting);
|
|
75
74
|
const [pagination, setPagination] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.pagination) || DEFAULT_INITIAL_STATE.pagination);
|
|
76
75
|
const [globalFilter, setGlobalFilter] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.globalFilter) || DEFAULT_INITIAL_STATE.globalFilter);
|
|
@@ -145,8 +144,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
145
144
|
const fetchData = (0, react_1.useCallback)((...args_1) => tslib_1.__awaiter(this, [...args_1], void 0, function* (overrides = {}) {
|
|
146
145
|
var _a, _b;
|
|
147
146
|
if (!onFetchData) {
|
|
148
|
-
if (
|
|
149
|
-
|
|
147
|
+
if (logger.isLevelEnabled('debug')) {
|
|
148
|
+
logger.debug('onFetchData not provided, skipping fetch', { overrides, columnFilter, sorting, pagination });
|
|
150
149
|
}
|
|
151
150
|
return;
|
|
152
151
|
}
|
|
@@ -154,13 +153,14 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
154
153
|
pagination,
|
|
155
154
|
columnFilter,
|
|
156
155
|
sorting }, overrides);
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
console.log('filters', filters);
|
|
157
|
+
if (logger.isLevelEnabled('info')) {
|
|
158
|
+
logger.info('Requesting data', { filters });
|
|
159
159
|
}
|
|
160
160
|
try {
|
|
161
161
|
const result = yield debouncedFetch(filters);
|
|
162
|
-
if (
|
|
163
|
-
|
|
162
|
+
if (logger.isLevelEnabled('info')) {
|
|
163
|
+
logger.info('Fetch resolved', {
|
|
164
164
|
rows: (_b = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
165
165
|
total: result === null || result === void 0 ? void 0 : result.total,
|
|
166
166
|
});
|
|
@@ -169,13 +169,13 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
169
169
|
setServerData(result.data);
|
|
170
170
|
setServerTotal(result.total);
|
|
171
171
|
}
|
|
172
|
-
else if (
|
|
173
|
-
|
|
172
|
+
else if (logger.isLevelEnabled('warn')) {
|
|
173
|
+
logger.warn('Fetch handler returned unexpected shape', result);
|
|
174
174
|
}
|
|
175
175
|
return result;
|
|
176
176
|
}
|
|
177
177
|
catch (error) {
|
|
178
|
-
|
|
178
|
+
logger.error('Fetch failed', error);
|
|
179
179
|
throw error;
|
|
180
180
|
}
|
|
181
181
|
}), [
|
|
@@ -185,7 +185,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
185
185
|
columnFilter,
|
|
186
186
|
sorting,
|
|
187
187
|
debouncedFetch,
|
|
188
|
-
|
|
188
|
+
logger,
|
|
189
189
|
]);
|
|
190
190
|
const handleSelectionStateChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
191
191
|
setSelectionState((prevState) => {
|
|
@@ -207,8 +207,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
207
207
|
}, [onColumnFiltersChange]);
|
|
208
208
|
const tableStateChange = (0, react_1.useCallback)((overrides = {}) => {
|
|
209
209
|
if (!onDataStateChange) {
|
|
210
|
-
if (
|
|
211
|
-
|
|
210
|
+
if (logger.isLevelEnabled('debug')) {
|
|
211
|
+
logger.debug('No onDataStateChange handler registered; skipping state update notification', { overrides });
|
|
212
212
|
}
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
@@ -218,10 +218,10 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
218
218
|
pagination,
|
|
219
219
|
columnOrder,
|
|
220
220
|
columnPinning }, overrides);
|
|
221
|
-
if (
|
|
222
|
-
|
|
221
|
+
if (logger.isLevelEnabled('debug')) {
|
|
222
|
+
logger.debug('Emitting tableStateChange', currentState);
|
|
223
223
|
}
|
|
224
|
-
onDataStateChange(currentState);
|
|
224
|
+
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(currentState);
|
|
225
225
|
}, [
|
|
226
226
|
onDataStateChange,
|
|
227
227
|
globalFilter,
|
|
@@ -230,7 +230,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
230
230
|
pagination,
|
|
231
231
|
columnOrder,
|
|
232
232
|
columnPinning,
|
|
233
|
-
|
|
233
|
+
logger,
|
|
234
234
|
]);
|
|
235
235
|
const handleSortingChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
236
236
|
let newSorting = typeof updaterOrValue === 'function'
|
|
@@ -239,8 +239,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
239
239
|
newSorting = newSorting.filter((sort) => sort.id);
|
|
240
240
|
setSorting(newSorting);
|
|
241
241
|
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(newSorting);
|
|
242
|
-
if (
|
|
243
|
-
|
|
242
|
+
if (logger.isLevelEnabled('debug')) {
|
|
243
|
+
logger.debug('Sorting change applied', {
|
|
244
244
|
sorting: newSorting,
|
|
245
245
|
serverMode: isServerMode,
|
|
246
246
|
serverSorting: isServerSorting,
|
|
@@ -248,8 +248,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
248
248
|
}
|
|
249
249
|
if (isServerMode || isServerSorting) {
|
|
250
250
|
const pagination = resetPageToFirst();
|
|
251
|
-
if (
|
|
252
|
-
|
|
251
|
+
if (logger.isLevelEnabled('debug')) {
|
|
252
|
+
logger.debug('Sorting change triggered server fetch', { pagination, sorting: newSorting });
|
|
253
253
|
}
|
|
254
254
|
tableStateChange({ sorting: newSorting, pagination });
|
|
255
255
|
fetchData({
|
|
@@ -260,8 +260,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
260
260
|
else if (onDataStateChange) {
|
|
261
261
|
const pagination = resetPageToFirst();
|
|
262
262
|
setTimeout(() => {
|
|
263
|
-
if (
|
|
264
|
-
|
|
263
|
+
if (logger.isLevelEnabled('debug')) {
|
|
264
|
+
logger.debug('Sorting change notified client state change', { pagination, sorting: newSorting });
|
|
265
265
|
}
|
|
266
266
|
tableStateChange({ sorting: newSorting, pagination });
|
|
267
267
|
}, 0);
|
|
@@ -274,7 +274,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
274
274
|
isServerSorting,
|
|
275
275
|
onDataStateChange,
|
|
276
276
|
tableStateChange,
|
|
277
|
-
|
|
277
|
+
logger,
|
|
278
278
|
]);
|
|
279
279
|
const handleColumnOrderChange = (0, react_1.useCallback)((updatedColumnOrder) => {
|
|
280
280
|
const newColumnOrder = typeof updatedColumnOrder === 'function'
|
|
@@ -294,24 +294,43 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
294
294
|
onColumnPinningChange(newColumnPinning);
|
|
295
295
|
}
|
|
296
296
|
}, [onColumnPinningChange, columnPinning]);
|
|
297
|
+
const handleColumnVisibilityChange = (0, react_1.useCallback)((updater) => {
|
|
298
|
+
var _a, _b;
|
|
299
|
+
const tableInstance = (_b = (_a = internalApiRef.current) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.getTable();
|
|
300
|
+
if (!tableInstance)
|
|
301
|
+
return;
|
|
302
|
+
const currentVisibility = tableInstance.getState().columnVisibility;
|
|
303
|
+
const newVisibility = typeof updater === 'function' ? updater(currentVisibility) : updater;
|
|
304
|
+
if (onColumnVisibilityChange) {
|
|
305
|
+
setTimeout(() => {
|
|
306
|
+
onColumnVisibilityChange(newVisibility);
|
|
307
|
+
}, 0);
|
|
308
|
+
}
|
|
309
|
+
if (onDataStateChange) {
|
|
310
|
+
setTimeout(() => {
|
|
311
|
+
tableStateChange({ columnVisibility: newVisibility });
|
|
312
|
+
}, 0);
|
|
313
|
+
}
|
|
314
|
+
}, [onColumnVisibilityChange, onDataStateChange, tableStateChange]);
|
|
297
315
|
const handlePaginationChange = (0, react_1.useCallback)((updater) => {
|
|
298
316
|
const newPagination = typeof updater === 'function' ? updater(pagination) : updater;
|
|
299
|
-
if (
|
|
300
|
-
|
|
317
|
+
if (logger.isLevelEnabled('debug')) {
|
|
318
|
+
logger.debug('Pagination change requested', {
|
|
301
319
|
previous: pagination,
|
|
302
320
|
next: newPagination,
|
|
303
321
|
serverSide: isServerMode || isServerPagination,
|
|
304
322
|
});
|
|
305
323
|
}
|
|
324
|
+
console.log('newPagination', newPagination);
|
|
306
325
|
setPagination(newPagination);
|
|
307
326
|
onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
|
|
308
|
-
if (
|
|
309
|
-
|
|
327
|
+
if (logger.isLevelEnabled('debug')) {
|
|
328
|
+
logger.debug('Pagination state updated', newPagination);
|
|
310
329
|
}
|
|
311
330
|
if (isServerMode || isServerPagination) {
|
|
312
331
|
setTimeout(() => {
|
|
313
|
-
if (
|
|
314
|
-
|
|
332
|
+
if (logger.isLevelEnabled('debug')) {
|
|
333
|
+
logger.debug('Notifying server-side pagination change', newPagination);
|
|
315
334
|
}
|
|
316
335
|
tableStateChange({ pagination: newPagination });
|
|
317
336
|
fetchData({ pagination: newPagination });
|
|
@@ -319,8 +338,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
319
338
|
}
|
|
320
339
|
else if (onDataStateChange) {
|
|
321
340
|
setTimeout(() => {
|
|
322
|
-
if (
|
|
323
|
-
|
|
341
|
+
if (logger.isLevelEnabled('debug')) {
|
|
342
|
+
logger.debug('Notifying client-side pagination change', newPagination);
|
|
324
343
|
}
|
|
325
344
|
tableStateChange({ pagination: newPagination });
|
|
326
345
|
}, 0);
|
|
@@ -332,7 +351,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
332
351
|
onDataStateChange,
|
|
333
352
|
fetchData,
|
|
334
353
|
tableStateChange,
|
|
335
|
-
|
|
354
|
+
logger,
|
|
336
355
|
onPaginationChange,
|
|
337
356
|
]);
|
|
338
357
|
const handleGlobalFilterChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
@@ -340,8 +359,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
340
359
|
? updaterOrValue(globalFilter)
|
|
341
360
|
: updaterOrValue;
|
|
342
361
|
setGlobalFilter(newFilter);
|
|
343
|
-
if (
|
|
344
|
-
|
|
362
|
+
if (logger.isLevelEnabled('debug')) {
|
|
363
|
+
logger.debug('Global filter change applied', {
|
|
345
364
|
value: newFilter,
|
|
346
365
|
serverMode: isServerMode,
|
|
347
366
|
serverFiltering: isServerFiltering,
|
|
@@ -350,8 +369,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
350
369
|
if (isServerMode || isServerFiltering) {
|
|
351
370
|
const pagination = resetPageToFirst();
|
|
352
371
|
setTimeout(() => {
|
|
353
|
-
if (
|
|
354
|
-
|
|
372
|
+
if (logger.isLevelEnabled('debug')) {
|
|
373
|
+
logger.debug('Global filter change triggering server fetch', {
|
|
355
374
|
pagination,
|
|
356
375
|
value: newFilter,
|
|
357
376
|
});
|
|
@@ -363,8 +382,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
363
382
|
else if (onDataStateChange) {
|
|
364
383
|
const pagination = resetPageToFirst();
|
|
365
384
|
setTimeout(() => {
|
|
366
|
-
if (
|
|
367
|
-
|
|
385
|
+
if (logger.isLevelEnabled('debug')) {
|
|
386
|
+
logger.debug('Global filter change notifying client listeners', {
|
|
368
387
|
pagination,
|
|
369
388
|
value: newFilter,
|
|
370
389
|
});
|
|
@@ -373,7 +392,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
373
392
|
}, 0);
|
|
374
393
|
}
|
|
375
394
|
onGlobalFilterChange === null || onGlobalFilterChange === void 0 ? void 0 : onGlobalFilterChange(newFilter);
|
|
376
|
-
}, [globalFilter, isServerMode, isServerFiltering, onDataStateChange, fetchData, tableStateChange,
|
|
395
|
+
}, [globalFilter, isServerMode, isServerFiltering, onDataStateChange, fetchData, tableStateChange, logger]);
|
|
377
396
|
const onColumnFilterChangeHandler = (0, react_1.useCallback)((updater) => {
|
|
378
397
|
const currentState = columnFilter;
|
|
379
398
|
const newState = typeof updater === 'function'
|
|
@@ -411,7 +430,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
411
430
|
}
|
|
412
431
|
}, 0);
|
|
413
432
|
}, [isServerFiltering, fetchData, tableStateChange]);
|
|
414
|
-
const table = (0, react_table_1.useReactTable)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ _features: [column_filter_feature_1.ColumnFilterFeature, features_1.SelectionFeature], data: tableData, columns: enhancedColumns, initialState: Object.assign({}, DEFAULT_INITIAL_STATE), state: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (enableSorting ? { sorting } : {})), (enablePagination ? { pagination } : {})), (enableGlobalFilter ? { globalFilter } : {})), (enableExpanding ? { expanded } : {})), (enableColumnDragging ? { columnOrder } : {})), (enableColumnPinning ? { columnPinning } : {})), (enableColumnFilter ? { columnFilter } : {})), (enableRowSelection ? { selectionState } : {})), selectMode: selectMode, enableAdvanceSelection: !!enableRowSelection, isRowSelectable: isRowSelectable }, (enableRowSelection ? { onSelectionStateChange: handleSelectionStateChange } : {})), { enableAdvanceColumnFilter: enableColumnFilter, onColumnFilterChange: onColumnFilterChangeHandler, onColumnFilterApply: onColumnFilterApplyHandler }), (enableSorting ? { onSortingChange: handleSortingChange } : {})), (enablePagination ? { onPaginationChange: handlePaginationChange } : {})), (enableRowSelection ? { onRowSelectionChange: handleSelectionStateChange } : {})), (enableGlobalFilter ? { onGlobalFilterChange: handleGlobalFilterChange } : {})), (enableExpanding ? { onExpandedChange: setExpanded } : {})), (enableColumnDragging ? { onColumnOrderChange: handleColumnOrderChange } : {})), (enableColumnPinning ? { onColumnPinningChange: handleColumnPinningChange } : {})), { getCoreRowModel: (0, react_table_1.getCoreRowModel)() }), (enableSorting ? { getSortedRowModel: (0, react_table_1.getSortedRowModel)() } : {})), (enableColumnFilter ? { getFilteredRowModel: (0, column_filter_feature_1.getCombinedFilteredRowModel)() } : {})), (enablePagination ? { getPaginationRowModel: (0, react_table_1.getPaginationRowModel)() } : {})), { enableSorting: enableSorting, manualSorting: isServerSorting, manualFiltering: isServerFiltering, enableColumnResizing: enableColumnResizing, columnResizeMode: columnResizeMode, enableColumnPinning: enableColumnPinning }), (enableExpanding ? { getRowCanExpand: getRowCanExpand } : {})), { manualPagination: isServerPagination, autoResetPageIndex: false, rowCount: tableTotalRow, getRowId: (row, index) => (0, utils_1.generateRowId)(row, index, idKey), debugAll: false }));
|
|
433
|
+
const table = (0, react_table_1.useReactTable)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ _features: [column_filter_feature_1.ColumnFilterFeature, features_1.SelectionFeature], data: tableData, columns: enhancedColumns, initialState: Object.assign({}, DEFAULT_INITIAL_STATE), state: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (enableSorting ? { sorting } : {})), (enablePagination ? { pagination } : {})), (enableGlobalFilter ? { globalFilter } : {})), (enableExpanding ? { expanded } : {})), (enableColumnDragging ? { columnOrder } : {})), (enableColumnPinning ? { columnPinning } : {})), (enableColumnFilter ? { columnFilter } : {})), (enableRowSelection ? { selectionState } : {})), selectMode: selectMode, enableAdvanceSelection: !!enableRowSelection, isRowSelectable: isRowSelectable }, (enableRowSelection ? { onSelectionStateChange: handleSelectionStateChange } : {})), { enableAdvanceColumnFilter: enableColumnFilter, onColumnFilterChange: onColumnFilterChangeHandler, onColumnFilterApply: onColumnFilterApplyHandler }), (enableSorting ? { onSortingChange: handleSortingChange } : {})), (enablePagination ? { onPaginationChange: handlePaginationChange } : {})), (enableRowSelection ? { onRowSelectionChange: handleSelectionStateChange } : {})), (enableGlobalFilter ? { onGlobalFilterChange: handleGlobalFilterChange } : {})), (enableExpanding ? { onExpandedChange: setExpanded } : {})), (enableColumnDragging ? { onColumnOrderChange: handleColumnOrderChange } : {})), (enableColumnPinning ? { onColumnPinningChange: handleColumnPinningChange } : {})), (enableColumnVisibility ? { onColumnVisibilityChange: handleColumnVisibilityChange } : {})), { getCoreRowModel: (0, react_table_1.getCoreRowModel)() }), (enableSorting ? { getSortedRowModel: (0, react_table_1.getSortedRowModel)() } : {})), (enableColumnFilter ? { getFilteredRowModel: (0, column_filter_feature_1.getCombinedFilteredRowModel)() } : {})), (enablePagination ? { getPaginationRowModel: (0, react_table_1.getPaginationRowModel)() } : {})), { enableSorting: enableSorting, manualSorting: isServerSorting, manualFiltering: isServerFiltering, enableColumnResizing: enableColumnResizing, columnResizeMode: columnResizeMode, enableColumnPinning: enableColumnPinning }), (enableExpanding ? { getRowCanExpand: getRowCanExpand } : {})), { manualPagination: isServerPagination, autoResetPageIndex: false, rowCount: tableTotalRow, getRowId: (row, index) => (0, utils_1.generateRowId)(row, index, idKey), debugAll: false }));
|
|
415
434
|
const rows = ((_a = table.getRowModel()) === null || _a === void 0 ? void 0 : _a.rows) || [];
|
|
416
435
|
const rowVirtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
417
436
|
count: rows.length,
|
|
@@ -421,8 +440,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
421
440
|
enabled: enableVirtualization && !enablePagination && rows.length > 0,
|
|
422
441
|
});
|
|
423
442
|
const resetPageToFirst = () => {
|
|
424
|
-
if (
|
|
425
|
-
|
|
443
|
+
if (logger.isLevelEnabled('info')) {
|
|
444
|
+
logger.info('Resetting to first page due to state change', {
|
|
426
445
|
previousPageIndex: pagination.pageIndex,
|
|
427
446
|
pageSize: pagination.pageSize,
|
|
428
447
|
});
|
|
@@ -430,6 +449,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
430
449
|
const newPagination = { pageIndex: 0, pageSize: pagination.pageSize };
|
|
431
450
|
setPagination(newPagination);
|
|
432
451
|
onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
|
|
452
|
+
console.log('newPagination', newPagination);
|
|
453
|
+
console.log('onPaginationChange', onPaginationChange);
|
|
433
454
|
return newPagination;
|
|
434
455
|
};
|
|
435
456
|
const handleColumnReorder = (0, react_1.useCallback)((draggedColumnId, targetColumnId) => {
|
|
@@ -453,13 +474,13 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
453
474
|
}, [columnOrder, enhancedColumns, handleColumnOrderChange]);
|
|
454
475
|
(0, react_1.useEffect)(() => {
|
|
455
476
|
if (initialLoadData && onFetchData) {
|
|
456
|
-
if (
|
|
457
|
-
|
|
477
|
+
if (logger.isLevelEnabled('info')) {
|
|
478
|
+
logger.info('Initial data load triggered', { initialLoadData });
|
|
458
479
|
}
|
|
459
480
|
fetchData();
|
|
460
481
|
}
|
|
461
|
-
else if (
|
|
462
|
-
|
|
482
|
+
else if (logger.isLevelEnabled('debug')) {
|
|
483
|
+
logger.debug('Skipping initial data load', {
|
|
463
484
|
initialLoadData,
|
|
464
485
|
hasOnFetchData: !!onFetchData
|
|
465
486
|
});
|
|
@@ -605,8 +626,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
605
626
|
pendingFilters: columnFilter.pendingFilters || [],
|
|
606
627
|
pendingLogic: columnFilter.pendingLogic || 'AND',
|
|
607
628
|
});
|
|
608
|
-
if (
|
|
609
|
-
|
|
629
|
+
if (logger.isLevelEnabled('debug')) {
|
|
630
|
+
logger.debug(`Adding column filter ${columnId} ${operator} ${value}`, newFilters);
|
|
610
631
|
}
|
|
611
632
|
},
|
|
612
633
|
removeColumnFilter: (filterId) => {
|
|
@@ -619,8 +640,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
619
640
|
pendingFilters: columnFilter.pendingFilters || [],
|
|
620
641
|
pendingLogic: columnFilter.pendingLogic || 'AND',
|
|
621
642
|
});
|
|
622
|
-
if (
|
|
623
|
-
|
|
643
|
+
if (logger.isLevelEnabled('debug')) {
|
|
644
|
+
logger.debug(`Removing column filter ${filterId}`, newFilters);
|
|
624
645
|
}
|
|
625
646
|
},
|
|
626
647
|
clearAllFilters: () => {
|
|
@@ -639,16 +660,16 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
639
660
|
pendingFilters: [],
|
|
640
661
|
pendingLogic: 'AND',
|
|
641
662
|
});
|
|
642
|
-
if (
|
|
643
|
-
|
|
663
|
+
if (logger.isLevelEnabled('debug')) {
|
|
664
|
+
logger.debug('Resetting filters');
|
|
644
665
|
}
|
|
645
666
|
},
|
|
646
667
|
},
|
|
647
668
|
sorting: {
|
|
648
669
|
setSorting: (sortingState) => {
|
|
649
670
|
table.setSorting(sortingState);
|
|
650
|
-
if (
|
|
651
|
-
|
|
671
|
+
if (logger.isLevelEnabled('debug')) {
|
|
672
|
+
logger.debug(`Setting sorting`, sortingState);
|
|
652
673
|
}
|
|
653
674
|
},
|
|
654
675
|
sortColumn: (columnId, direction) => {
|
|
@@ -672,40 +693,40 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
672
693
|
pagination: {
|
|
673
694
|
goToPage: (pageIndex) => {
|
|
674
695
|
table.setPageIndex(pageIndex);
|
|
675
|
-
if (
|
|
676
|
-
|
|
696
|
+
if (logger.isLevelEnabled('debug')) {
|
|
697
|
+
logger.debug(`Going to page ${pageIndex}`);
|
|
677
698
|
}
|
|
678
699
|
},
|
|
679
700
|
nextPage: () => {
|
|
680
701
|
table.nextPage();
|
|
681
|
-
if (
|
|
682
|
-
|
|
702
|
+
if (logger.isLevelEnabled('debug')) {
|
|
703
|
+
logger.debug('Next page');
|
|
683
704
|
}
|
|
684
705
|
},
|
|
685
706
|
previousPage: () => {
|
|
686
707
|
table.previousPage();
|
|
687
|
-
if (
|
|
688
|
-
|
|
708
|
+
if (logger.isLevelEnabled('debug')) {
|
|
709
|
+
logger.debug('Previous page');
|
|
689
710
|
}
|
|
690
711
|
},
|
|
691
712
|
setPageSize: (pageSize) => {
|
|
692
713
|
table.setPageSize(pageSize);
|
|
693
|
-
if (
|
|
694
|
-
|
|
714
|
+
if (logger.isLevelEnabled('debug')) {
|
|
715
|
+
logger.debug(`Setting page size to ${pageSize}`);
|
|
695
716
|
}
|
|
696
717
|
},
|
|
697
718
|
goToFirstPage: () => {
|
|
698
719
|
table.setPageIndex(0);
|
|
699
|
-
if (
|
|
700
|
-
|
|
720
|
+
if (logger.isLevelEnabled('debug')) {
|
|
721
|
+
logger.debug('Going to first page');
|
|
701
722
|
}
|
|
702
723
|
},
|
|
703
724
|
goToLastPage: () => {
|
|
704
725
|
const pageCount = table.getPageCount();
|
|
705
726
|
if (pageCount > 0) {
|
|
706
727
|
table.setPageIndex(pageCount - 1);
|
|
707
|
-
if (
|
|
708
|
-
|
|
728
|
+
if (logger.isLevelEnabled('debug')) {
|
|
729
|
+
logger.debug(`Going to last page ${pageCount - 1}`);
|
|
709
730
|
}
|
|
710
731
|
}
|
|
711
732
|
},
|
|
@@ -726,27 +747,27 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
726
747
|
isRowSelected: (rowId) => table.getIsRowSelected(rowId) || false,
|
|
727
748
|
},
|
|
728
749
|
data: {
|
|
729
|
-
refresh: () => {
|
|
730
|
-
var _a, _b;
|
|
750
|
+
refresh: (resetPagination = false) => {
|
|
751
|
+
var _a, _b, _c;
|
|
731
752
|
const filters = table.getState();
|
|
732
753
|
const pagination = {
|
|
733
|
-
pageIndex: 0,
|
|
734
|
-
pageSize: ((
|
|
754
|
+
pageIndex: resetPagination ? 0 : ((_a = initialStateConfig.pagination) === null || _a === void 0 ? void 0 : _a.pageIndex) || 0,
|
|
755
|
+
pageSize: ((_b = filters.pagination) === null || _b === void 0 ? void 0 : _b.pageSize) || ((_c = initialStateConfig.pagination) === null || _c === void 0 ? void 0 : _c.pageSize) || 10,
|
|
735
756
|
};
|
|
736
757
|
const allState = table.getState();
|
|
737
758
|
setPagination(pagination);
|
|
738
|
-
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
759
|
+
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(Object.assign(Object.assign({}, allState), { pagination }));
|
|
739
760
|
fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination });
|
|
740
|
-
if (
|
|
741
|
-
|
|
761
|
+
if (logger.isLevelEnabled('debug')) {
|
|
762
|
+
logger.debug('Refreshing data using Ref', { pagination, allState });
|
|
742
763
|
}
|
|
743
764
|
},
|
|
744
765
|
reload: () => {
|
|
745
766
|
const allState = table.getState();
|
|
746
767
|
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
747
768
|
onFetchData === null || onFetchData === void 0 ? void 0 : onFetchData({});
|
|
748
|
-
if (
|
|
749
|
-
|
|
769
|
+
if (logger.isLevelEnabled('debug')) {
|
|
770
|
+
logger.info('Reloading data', allState);
|
|
750
771
|
}
|
|
751
772
|
},
|
|
752
773
|
getAllData: () => {
|
|
@@ -766,8 +787,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
766
787
|
const newData = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map(row => String(row.original[idKey]) === rowId
|
|
767
788
|
? Object.assign(Object.assign({}, row.original), updates) : row.original);
|
|
768
789
|
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData || []);
|
|
769
|
-
if (
|
|
770
|
-
|
|
790
|
+
if (logger.isLevelEnabled('debug')) {
|
|
791
|
+
logger.debug(`Updating row ${rowId}`, updates);
|
|
771
792
|
}
|
|
772
793
|
},
|
|
773
794
|
updateRowByIndex: (index, updates) => {
|
|
@@ -776,8 +797,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
776
797
|
if (newData === null || newData === void 0 ? void 0 : newData[index]) {
|
|
777
798
|
newData[index] = Object.assign(Object.assign({}, newData[index]), updates);
|
|
778
799
|
setServerData(newData);
|
|
779
|
-
if (
|
|
780
|
-
|
|
800
|
+
if (logger.isLevelEnabled('debug')) {
|
|
801
|
+
logger.debug(`Updating row by index ${index}`, updates);
|
|
781
802
|
}
|
|
782
803
|
}
|
|
783
804
|
},
|
|
@@ -791,16 +812,16 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
791
812
|
newData.push(newRow);
|
|
792
813
|
}
|
|
793
814
|
setServerData(newData || []);
|
|
794
|
-
if (
|
|
795
|
-
|
|
815
|
+
if (logger.isLevelEnabled('debug')) {
|
|
816
|
+
logger.debug(`Inserting row`, newRow);
|
|
796
817
|
}
|
|
797
818
|
},
|
|
798
819
|
deleteRow: (rowId) => {
|
|
799
820
|
var _a;
|
|
800
821
|
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.filter(row => String(row.original[idKey]) !== rowId);
|
|
801
822
|
setServerData === null || setServerData === void 0 ? void 0 : setServerData((newData === null || newData === void 0 ? void 0 : newData.map(row => row.original)) || []);
|
|
802
|
-
if (
|
|
803
|
-
|
|
823
|
+
if (logger.isLevelEnabled('debug')) {
|
|
824
|
+
logger.debug(`Deleting row ${rowId}`);
|
|
804
825
|
}
|
|
805
826
|
},
|
|
806
827
|
deleteRowByIndex: (index) => {
|
|
@@ -808,8 +829,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
808
829
|
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.map(row => row.original);
|
|
809
830
|
newData.splice(index, 1);
|
|
810
831
|
setServerData(newData);
|
|
811
|
-
if (
|
|
812
|
-
|
|
832
|
+
if (logger.isLevelEnabled('debug')) {
|
|
833
|
+
logger.debug(`Deleting row by index ${index}`);
|
|
813
834
|
}
|
|
814
835
|
},
|
|
815
836
|
deleteSelectedRows: () => {
|
|
@@ -819,8 +840,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
819
840
|
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.filter(row => !selectedRowIds.includes(String(row.original[idKey])));
|
|
820
841
|
setServerData((newData === null || newData === void 0 ? void 0 : newData.map(row => row.original)) || []);
|
|
821
842
|
table.resetRowSelection();
|
|
822
|
-
if (
|
|
823
|
-
|
|
843
|
+
if (logger.isLevelEnabled('debug')) {
|
|
844
|
+
logger.debug('Deleting selected rows');
|
|
824
845
|
}
|
|
825
846
|
},
|
|
826
847
|
replaceAllData: (newData) => {
|
|
@@ -978,8 +999,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
978
999
|
sorting: table.getState().sorting,
|
|
979
1000
|
pagination: table.getState().pagination,
|
|
980
1001
|
};
|
|
981
|
-
if (
|
|
982
|
-
|
|
1002
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1003
|
+
logger.debug('Server export CSV', { currentFilters });
|
|
983
1004
|
}
|
|
984
1005
|
yield (0, utils_1.exportServerData)(table, {
|
|
985
1006
|
format: 'csv',
|
|
@@ -1000,8 +1021,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1000
1021
|
onComplete: onExportComplete,
|
|
1001
1022
|
onError: onExportError,
|
|
1002
1023
|
});
|
|
1003
|
-
if (
|
|
1004
|
-
|
|
1024
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1025
|
+
logger.debug('Client export CSV', filename);
|
|
1005
1026
|
}
|
|
1006
1027
|
}
|
|
1007
1028
|
}
|
|
@@ -1028,8 +1049,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1028
1049
|
sorting: table.getState().sorting,
|
|
1029
1050
|
pagination: table.getState().pagination,
|
|
1030
1051
|
};
|
|
1031
|
-
if (
|
|
1032
|
-
|
|
1052
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1053
|
+
logger.debug('Server export Excel', { currentFilters });
|
|
1033
1054
|
}
|
|
1034
1055
|
yield (0, utils_1.exportServerData)(table, {
|
|
1035
1056
|
format: 'excel',
|
|
@@ -1050,8 +1071,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1050
1071
|
onComplete: onExportComplete,
|
|
1051
1072
|
onError: onExportError,
|
|
1052
1073
|
});
|
|
1053
|
-
if (
|
|
1054
|
-
|
|
1074
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1075
|
+
logger.debug('Client export Excel', filename);
|
|
1055
1076
|
}
|
|
1056
1077
|
}
|
|
1057
1078
|
}
|
|
@@ -1060,8 +1081,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1060
1081
|
message: error.message || 'Export failed',
|
|
1061
1082
|
code: 'EXPORT_ERROR',
|
|
1062
1083
|
});
|
|
1063
|
-
if (
|
|
1064
|
-
|
|
1084
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1085
|
+
logger.debug('Server export Excel failed', error);
|
|
1065
1086
|
}
|
|
1066
1087
|
}
|
|
1067
1088
|
finally {
|
|
@@ -1076,8 +1097,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1076
1097
|
message: 'No server export function provided',
|
|
1077
1098
|
code: 'NO_SERVER_EXPORT',
|
|
1078
1099
|
});
|
|
1079
|
-
if (
|
|
1080
|
-
|
|
1100
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1101
|
+
logger.debug('Server export data failed', 'No server export function provided');
|
|
1081
1102
|
}
|
|
1082
1103
|
return;
|
|
1083
1104
|
}
|
|
@@ -1090,8 +1111,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1090
1111
|
sorting: table.getState().sorting,
|
|
1091
1112
|
pagination: table.getState().pagination,
|
|
1092
1113
|
};
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1114
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1115
|
+
logger.debug('Server export data', { currentFilters });
|
|
1095
1116
|
}
|
|
1096
1117
|
yield (0, utils_1.exportServerData)(table, {
|
|
1097
1118
|
format,
|
|
@@ -1109,8 +1130,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1109
1130
|
message: error.message || 'Export failed',
|
|
1110
1131
|
code: 'EXPORT_ERROR',
|
|
1111
1132
|
});
|
|
1112
|
-
if (
|
|
1113
|
-
|
|
1133
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1134
|
+
logger.debug('Server export data failed', error);
|
|
1114
1135
|
}
|
|
1115
1136
|
}
|
|
1116
1137
|
finally {
|
|
@@ -1121,8 +1142,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1121
1142
|
cancelExport: () => {
|
|
1122
1143
|
exportController === null || exportController === void 0 ? void 0 : exportController.abort();
|
|
1123
1144
|
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1145
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1146
|
+
logger.debug('Export cancelled');
|
|
1126
1147
|
}
|
|
1127
1148
|
},
|
|
1128
1149
|
},
|
|
@@ -61,6 +61,8 @@ export interface DataTableProps<T> {
|
|
|
61
61
|
onColumnDragEnd?: (columnOrder: string[]) => void;
|
|
62
62
|
enableColumnPinning?: boolean;
|
|
63
63
|
onColumnPinningChange?: (pinning: ColumnPinningState) => void;
|
|
64
|
+
enableColumnVisibility?: boolean;
|
|
65
|
+
onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
|
|
64
66
|
enableExpanding?: boolean;
|
|
65
67
|
getRowCanExpand?: (row: Row<T>) => boolean;
|
|
66
68
|
renderSubComponent?: (row: Row<T>) => ReactNode;
|
|
@@ -82,7 +84,6 @@ export interface DataTableProps<T> {
|
|
|
82
84
|
maxHeight?: string | number;
|
|
83
85
|
enableVirtualization?: boolean;
|
|
84
86
|
estimateRowHeight?: number;
|
|
85
|
-
enableColumnVisibility?: boolean;
|
|
86
87
|
enableTableSizeControl?: boolean;
|
|
87
88
|
enableExport?: boolean;
|
|
88
89
|
enableReset?: boolean;
|
|
@@ -20,16 +20,16 @@ function ColumnPinningControl(props = {}) {
|
|
|
20
20
|
const UnpinIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'unpinIcon', icons_1.UnpinIcon);
|
|
21
21
|
const LeftIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'leftIcon', icons_material_1.ArrowLeftOutlined);
|
|
22
22
|
const RightIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'rightIcon', icons_material_1.ArrowRightOutlined);
|
|
23
|
-
const columnPinning = table.getState().columnPinning;
|
|
23
|
+
const columnPinning = (table === null || table === void 0 ? void 0 : table.getState().columnPinning) || {};
|
|
24
24
|
const allColumns = (0, react_1.useMemo)(() => {
|
|
25
|
-
var _a, _b;
|
|
25
|
+
var _a, _b, _c;
|
|
26
26
|
if ((_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _a === void 0 ? void 0 : _a.getPinnableColumns) {
|
|
27
|
-
return (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _b === void 0 ? void 0 : _b.getPinnableColumns(table.getAllLeafColumns());
|
|
27
|
+
return (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _b === void 0 ? void 0 : _b.getPinnableColumns((table === null || table === void 0 ? void 0 : table.getAllLeafColumns()) || []);
|
|
28
28
|
}
|
|
29
|
-
return table.getAllLeafColumns().filter(column => column.getCanPin());
|
|
29
|
+
return ((_c = table === null || table === void 0 ? void 0 : table.getAllLeafColumns()) === null || _c === void 0 ? void 0 : _c.filter(column => column.getCanPin())) || [];
|
|
30
30
|
}, [slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel, table]);
|
|
31
31
|
const handlePinColumn = (columnId, position) => {
|
|
32
|
-
const currentPinning = table.getState().columnPinning;
|
|
32
|
+
const currentPinning = (table === null || table === void 0 ? void 0 : table.getState().columnPinning) || {};
|
|
33
33
|
const newPinning = Object.assign({}, currentPinning);
|
|
34
34
|
newPinning.left = (newPinning.left || []).filter(id => id !== columnId);
|
|
35
35
|
newPinning.right = (newPinning.right || []).filter(id => id !== columnId);
|
|
@@ -39,7 +39,7 @@ function ColumnPinningControl(props = {}) {
|
|
|
39
39
|
else if (position === 'right') {
|
|
40
40
|
newPinning.right = [...(newPinning.right || []), columnId];
|
|
41
41
|
}
|
|
42
|
-
table.setColumnPinning(newPinning);
|
|
42
|
+
table === null || table === void 0 ? void 0 : table.setColumnPinning(newPinning);
|
|
43
43
|
};
|
|
44
44
|
const getColumnPinStatus = (columnId) => {
|
|
45
45
|
var _a, _b;
|
|
@@ -13,15 +13,15 @@ function ColumnVisibilityControl(props = {}) {
|
|
|
13
13
|
const iconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'columnIcon');
|
|
14
14
|
const ColumnIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnIcon', icons_material_1.ViewColumnOutlined);
|
|
15
15
|
const columns = (0, react_1.useMemo)(() => {
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
if ((_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _a === void 0 ? void 0 : _a.getTogglableColumns) {
|
|
18
|
-
return (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _b === void 0 ? void 0 : _b.getTogglableColumns(table.getAllLeafColumns());
|
|
18
|
+
return (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel) === null || _b === void 0 ? void 0 : _b.getTogglableColumns((table === null || table === void 0 ? void 0 : table.getAllLeafColumns()) || []);
|
|
19
19
|
}
|
|
20
|
-
return table.getAllLeafColumns().filter(column => column.getCanHide());
|
|
20
|
+
return ((_c = table === null || table === void 0 ? void 0 : table.getAllLeafColumns()) === null || _c === void 0 ? void 0 : _c.filter(column => column.getCanHide())) || [];
|
|
21
21
|
}, [slotProps === null || slotProps === void 0 ? void 0 : slotProps.columnsPanel, table]);
|
|
22
22
|
const handleColumnVisibilityChange = ((columnId, visible) => {
|
|
23
23
|
var _a;
|
|
24
|
-
(_a = table.getColumn(columnId)) === null || _a === void 0 ? void 0 : _a.toggleVisibility(visible);
|
|
24
|
+
(_a = table === null || table === void 0 ? void 0 : table.getColumn(columnId)) === null || _a === void 0 ? void 0 : _a.toggleVisibility(visible);
|
|
25
25
|
});
|
|
26
26
|
const mergedProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
27
27
|
size: 'small',
|
|
@@ -68,7 +68,7 @@ export interface DataTableApi<T = any> {
|
|
|
68
68
|
isRowSelected: (rowId: string) => boolean;
|
|
69
69
|
};
|
|
70
70
|
data: {
|
|
71
|
-
refresh: () => void;
|
|
71
|
+
refresh: (resetPagination?: boolean) => void;
|
|
72
72
|
reload: () => void;
|
|
73
73
|
getAllData: () => T[];
|
|
74
74
|
getRowData: (rowId: string) => T | undefined;
|